julia.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/julia/julia.ts
  8. var 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. var language = {
  30. tokenPostfix: ".julia",
  31. keywords: [
  32. "begin",
  33. "while",
  34. "if",
  35. "for",
  36. "try",
  37. "return",
  38. "break",
  39. "continue",
  40. "function",
  41. "macro",
  42. "quote",
  43. "let",
  44. "local",
  45. "global",
  46. "const",
  47. "do",
  48. "struct",
  49. "module",
  50. "baremodule",
  51. "using",
  52. "import",
  53. "export",
  54. "end",
  55. "else",
  56. "elseif",
  57. "catch",
  58. "finally",
  59. "mutable",
  60. "primitive",
  61. "abstract",
  62. "type",
  63. "in",
  64. "isa",
  65. "where",
  66. "new"
  67. ],
  68. types: [
  69. "LinRange",
  70. "LineNumberNode",
  71. "LinearIndices",
  72. "LoadError",
  73. "MIME",
  74. "Matrix",
  75. "Method",
  76. "MethodError",
  77. "Missing",
  78. "MissingException",
  79. "Module",
  80. "NTuple",
  81. "NamedTuple",
  82. "Nothing",
  83. "Number",
  84. "OrdinalRange",
  85. "OutOfMemoryError",
  86. "OverflowError",
  87. "Pair",
  88. "PartialQuickSort",
  89. "PermutedDimsArray",
  90. "Pipe",
  91. "Ptr",
  92. "QuoteNode",
  93. "Rational",
  94. "RawFD",
  95. "ReadOnlyMemoryError",
  96. "Real",
  97. "ReentrantLock",
  98. "Ref",
  99. "Regex",
  100. "RegexMatch",
  101. "RoundingMode",
  102. "SegmentationFault",
  103. "Set",
  104. "Signed",
  105. "Some",
  106. "StackOverflowError",
  107. "StepRange",
  108. "StepRangeLen",
  109. "StridedArray",
  110. "StridedMatrix",
  111. "StridedVecOrMat",
  112. "StridedVector",
  113. "String",
  114. "StringIndexError",
  115. "SubArray",
  116. "SubString",
  117. "SubstitutionString",
  118. "Symbol",
  119. "SystemError",
  120. "Task",
  121. "Text",
  122. "TextDisplay",
  123. "Timer",
  124. "Tuple",
  125. "Type",
  126. "TypeError",
  127. "TypeVar",
  128. "UInt",
  129. "UInt128",
  130. "UInt16",
  131. "UInt32",
  132. "UInt64",
  133. "UInt8",
  134. "UndefInitializer",
  135. "AbstractArray",
  136. "UndefKeywordError",
  137. "AbstractChannel",
  138. "UndefRefError",
  139. "AbstractChar",
  140. "UndefVarError",
  141. "AbstractDict",
  142. "Union",
  143. "AbstractDisplay",
  144. "UnionAll",
  145. "AbstractFloat",
  146. "UnitRange",
  147. "AbstractIrrational",
  148. "Unsigned",
  149. "AbstractMatrix",
  150. "AbstractRange",
  151. "Val",
  152. "AbstractSet",
  153. "Vararg",
  154. "AbstractString",
  155. "VecElement",
  156. "AbstractUnitRange",
  157. "VecOrMat",
  158. "AbstractVecOrMat",
  159. "Vector",
  160. "AbstractVector",
  161. "VersionNumber",
  162. "Any",
  163. "WeakKeyDict",
  164. "ArgumentError",
  165. "WeakRef",
  166. "Array",
  167. "AssertionError",
  168. "BigFloat",
  169. "BigInt",
  170. "BitArray",
  171. "BitMatrix",
  172. "BitSet",
  173. "BitVector",
  174. "Bool",
  175. "BoundsError",
  176. "CapturedException",
  177. "CartesianIndex",
  178. "CartesianIndices",
  179. "Cchar",
  180. "Cdouble",
  181. "Cfloat",
  182. "Channel",
  183. "Char",
  184. "Cint",
  185. "Cintmax_t",
  186. "Clong",
  187. "Clonglong",
  188. "Cmd",
  189. "Colon",
  190. "Complex",
  191. "ComplexF16",
  192. "ComplexF32",
  193. "ComplexF64",
  194. "CompositeException",
  195. "Condition",
  196. "Cptrdiff_t",
  197. "Cshort",
  198. "Csize_t",
  199. "Cssize_t",
  200. "Cstring",
  201. "Cuchar",
  202. "Cuint",
  203. "Cuintmax_t",
  204. "Culong",
  205. "Culonglong",
  206. "Cushort",
  207. "Cvoid",
  208. "Cwchar_t",
  209. "Cwstring",
  210. "DataType",
  211. "DenseArray",
  212. "DenseMatrix",
  213. "DenseVecOrMat",
  214. "DenseVector",
  215. "Dict",
  216. "DimensionMismatch",
  217. "Dims",
  218. "DivideError",
  219. "DomainError",
  220. "EOFError",
  221. "Enum",
  222. "ErrorException",
  223. "Exception",
  224. "ExponentialBackOff",
  225. "Expr",
  226. "Float16",
  227. "Float32",
  228. "Float64",
  229. "Function",
  230. "GlobalRef",
  231. "HTML",
  232. "IO",
  233. "IOBuffer",
  234. "IOContext",
  235. "IOStream",
  236. "IdDict",
  237. "IndexCartesian",
  238. "IndexLinear",
  239. "IndexStyle",
  240. "InexactError",
  241. "InitError",
  242. "Int",
  243. "Int128",
  244. "Int16",
  245. "Int32",
  246. "Int64",
  247. "Int8",
  248. "Integer",
  249. "InterruptException",
  250. "InvalidStateException",
  251. "Irrational",
  252. "KeyError"
  253. ],
  254. keywordops: ["<:", ">:", ":", "=>", "...", ".", "->", "?"],
  255. allops: /[^\w\d\s()\[\]{}"'#]+/,
  256. constants: [
  257. "true",
  258. "false",
  259. "nothing",
  260. "missing",
  261. "undef",
  262. "Inf",
  263. "pi",
  264. "NaN",
  265. "\u03C0",
  266. "\u212F",
  267. "ans",
  268. "PROGRAM_FILE",
  269. "ARGS",
  270. "C_NULL",
  271. "VERSION",
  272. "DEPOT_PATH",
  273. "LOAD_PATH"
  274. ],
  275. operators: [
  276. "!",
  277. "!=",
  278. "!==",
  279. "%",
  280. "&",
  281. "*",
  282. "+",
  283. "-",
  284. "/",
  285. "//",
  286. "<",
  287. "<<",
  288. "<=",
  289. "==",
  290. "===",
  291. "=>",
  292. ">",
  293. ">=",
  294. ">>",
  295. ">>>",
  296. "\\",
  297. "^",
  298. "|",
  299. "|>",
  300. "~",
  301. "\xF7",
  302. "\u2208",
  303. "\u2209",
  304. "\u220B",
  305. "\u220C",
  306. "\u2218",
  307. "\u221A",
  308. "\u221B",
  309. "\u2229",
  310. "\u222A",
  311. "\u2248",
  312. "\u2249",
  313. "\u2260",
  314. "\u2261",
  315. "\u2262",
  316. "\u2264",
  317. "\u2265",
  318. "\u2286",
  319. "\u2287",
  320. "\u2288",
  321. "\u2289",
  322. "\u228A",
  323. "\u228B",
  324. "\u22BB"
  325. ],
  326. brackets: [
  327. { open: "(", close: ")", token: "delimiter.parenthesis" },
  328. { open: "{", close: "}", token: "delimiter.curly" },
  329. { open: "[", close: "]", token: "delimiter.square" }
  330. ],
  331. ident: /π|ℯ|\b(?!\d)\w+\b/,
  332. escape: /(?:[abefnrstv\\"'\n\r]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4})/,
  333. escapes: /\\(?:C\-(@escape|.)|c(@escape|.)|@escape)/,
  334. tokenizer: {
  335. root: [
  336. [/(::)\s*|\b(isa)\s+/, "keyword", "@typeanno"],
  337. [/\b(isa)(\s*\(@ident\s*,\s*)/, ["keyword", { token: "", next: "@typeanno" }]],
  338. [/\b(type|struct)[ \t]+/, "keyword", "@typeanno"],
  339. [/^\s*:@ident[!?]?/, "metatag"],
  340. [/(return)(\s*:@ident[!?]?)/, ["keyword", "metatag"]],
  341. [/(\(|\[|\{|@allops)(\s*:@ident[!?]?)/, ["", "metatag"]],
  342. [/:\(/, "metatag", "@quote"],
  343. [/r"""/, "regexp.delim", "@tregexp"],
  344. [/r"/, "regexp.delim", "@sregexp"],
  345. [/raw"""/, "string.delim", "@rtstring"],
  346. [/[bv]?"""/, "string.delim", "@dtstring"],
  347. [/raw"/, "string.delim", "@rsstring"],
  348. [/[bv]?"/, "string.delim", "@dsstring"],
  349. [
  350. /(@ident)\{/,
  351. {
  352. cases: {
  353. "$1@types": { token: "type", next: "@gen" },
  354. "@default": { token: "type", next: "@gen" }
  355. }
  356. }
  357. ],
  358. [
  359. /@ident[!?'']?(?=\.?\()/,
  360. {
  361. cases: {
  362. "@types": "type",
  363. "@keywords": "keyword",
  364. "@constants": "variable",
  365. "@default": "keyword.flow"
  366. }
  367. }
  368. ],
  369. [
  370. /@ident[!?']?/,
  371. {
  372. cases: {
  373. "@types": "type",
  374. "@keywords": "keyword",
  375. "@constants": "variable",
  376. "@default": "identifier"
  377. }
  378. }
  379. ],
  380. [/\$\w+/, "key"],
  381. [/\$\(/, "key", "@paste"],
  382. [/@@@ident/, "annotation"],
  383. { include: "@whitespace" },
  384. [/'(?:@escapes|.)'/, "string.character"],
  385. [/[()\[\]{}]/, "@brackets"],
  386. [
  387. /@allops/,
  388. {
  389. cases: {
  390. "@keywordops": "keyword",
  391. "@operators": "operator"
  392. }
  393. }
  394. ],
  395. [/[;,]/, "delimiter"],
  396. [/0[xX][0-9a-fA-F](_?[0-9a-fA-F])*/, "number.hex"],
  397. [/0[_oO][0-7](_?[0-7])*/, "number.octal"],
  398. [/0[bB][01](_?[01])*/, "number.binary"],
  399. [/[+\-]?\d+(\.\d+)?(im?|[eE][+\-]?\d+(\.\d+)?)?/, "number"]
  400. ],
  401. typeanno: [
  402. [/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\{/, "type", "@gen"],
  403. [/([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(\s*<:\s*)/, ["type", "keyword"]],
  404. [/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*/, "type", "@pop"],
  405. ["", "", "@pop"]
  406. ],
  407. gen: [
  408. [/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\{/, "type", "@push"],
  409. [/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*/, "type"],
  410. [/<:/, "keyword"],
  411. [/(\})(\s*<:\s*)/, ["type", { token: "keyword", next: "@pop" }]],
  412. [/\}/, "type", "@pop"],
  413. { include: "@root" }
  414. ],
  415. quote: [
  416. [/\$\(/, "key", "@paste"],
  417. [/\(/, "@brackets", "@paren"],
  418. [/\)/, "metatag", "@pop"],
  419. { include: "@root" }
  420. ],
  421. paste: [
  422. [/:\(/, "metatag", "@quote"],
  423. [/\(/, "@brackets", "@paren"],
  424. [/\)/, "key", "@pop"],
  425. { include: "@root" }
  426. ],
  427. paren: [
  428. [/\$\(/, "key", "@paste"],
  429. [/:\(/, "metatag", "@quote"],
  430. [/\(/, "@brackets", "@push"],
  431. [/\)/, "@brackets", "@pop"],
  432. { include: "@root" }
  433. ],
  434. sregexp: [
  435. [/^.*/, "invalid"],
  436. [/[^\\"()\[\]{}]/, "regexp"],
  437. [/[()\[\]{}]/, "@brackets"],
  438. [/\\./, "operator.scss"],
  439. [/"[imsx]*/, "regexp.delim", "@pop"]
  440. ],
  441. tregexp: [
  442. [/[^\\"()\[\]{}]/, "regexp"],
  443. [/[()\[\]{}]/, "@brackets"],
  444. [/\\./, "operator.scss"],
  445. [/"(?!"")/, "string"],
  446. [/"""[imsx]*/, "regexp.delim", "@pop"]
  447. ],
  448. rsstring: [
  449. [/^.*/, "invalid"],
  450. [/[^\\"]/, "string"],
  451. [/\\./, "string.escape"],
  452. [/"/, "string.delim", "@pop"]
  453. ],
  454. rtstring: [
  455. [/[^\\"]/, "string"],
  456. [/\\./, "string.escape"],
  457. [/"(?!"")/, "string"],
  458. [/"""/, "string.delim", "@pop"]
  459. ],
  460. dsstring: [
  461. [/^.*/, "invalid"],
  462. [/[^\\"\$]/, "string"],
  463. [/\$/, "", "@interpolated"],
  464. [/@escapes/, "string.escape"],
  465. [/\\./, "string.escape.invalid"],
  466. [/"/, "string.delim", "@pop"]
  467. ],
  468. dtstring: [
  469. [/[^\\"\$]/, "string"],
  470. [/\$/, "", "@interpolated"],
  471. [/@escapes/, "string.escape"],
  472. [/\\./, "string.escape.invalid"],
  473. [/"(?!"")/, "string"],
  474. [/"""/, "string.delim", "@pop"]
  475. ],
  476. interpolated: [
  477. [/\(/, { token: "", switchTo: "@interpolated_compound" }],
  478. [/[a-zA-Z_]\w*/, "identifier"],
  479. ["", "", "@pop"]
  480. ],
  481. interpolated_compound: [[/\)/, "", "@pop"], { include: "@root" }],
  482. whitespace: [
  483. [/[ \t\r\n]+/, ""],
  484. [/#=/, "comment", "@multi_comment"],
  485. [/#.*$/, "comment"]
  486. ],
  487. multi_comment: [
  488. [/#=/, "comment", "@push"],
  489. [/=#/, "comment", "@pop"],
  490. [/=(?!#)|#(?!=)/, "comment"],
  491. [/[^#=]+/, "comment"]
  492. ]
  493. }
  494. };
  495. export {
  496. conf,
  497. language
  498. };