julia.js 15 KB

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