_julia_builtins.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. """
  2. pygments.lexers._julia_builtins
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Julia builtins.
  5. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. # operators
  9. # see https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm
  10. # Julia v1.6.0-rc1
  11. OPERATORS_LIST = [
  12. # other
  13. '->',
  14. # prec-assignment
  15. ':=', '$=',
  16. # prec-conditional, prec-lazy-or, prec-lazy-and
  17. '?', '||', '&&',
  18. # prec-colon
  19. ':',
  20. # prec-plus
  21. '$',
  22. # prec-decl
  23. '::',
  24. ]
  25. DOTTED_OPERATORS_LIST = [
  26. # prec-assignment
  27. r'=', r'+=', r'-=', r'*=', r'/=', r'//=', r'\=', r'^=', r'÷=', r'%=', r'<<=',
  28. r'>>=', r'>>>=', r'|=', r'&=', r'⊻=', r'≔', r'⩴', r"≕'", r'~',
  29. # prec-pair
  30. '=>',
  31. # prec-arrow
  32. r'→', r'↔', r'↚', r'↛', r'↞', r'↠', r'↢', r'↣', r'↦', r'↤', r'↮', r'⇎', r'⇍', r'⇏',
  33. r'⇐', r'⇒', r'⇔', r'⇴', r'⇶', r'⇷', r'⇸', r'⇹', r'⇺', r'⇻', r'⇼', r'⇽', r'⇾', r'⇿',
  34. r'⟵', r'⟶', r'⟷', r'⟹', r'⟺', r'⟻', r'⟼', r'⟽', r'⟾', r'⟿', r'⤀', r'⤁', r'⤂', r'⤃',
  35. r'⤄', r'⤅', r'⤆', r'⤇', r'⤌', r'⤍', r'⤎', r'⤏', r'⤐', r'⤑', r'⤔', r'⤕', r'⤖', r'⤗',
  36. r'⤘', r'⤝', r'⤞', r'⤟', r'⤠', r'⥄', r'⥅', r'⥆', r'⥇', r'⥈', r'⥊', r'⥋', r'⥎', r'⥐',
  37. r'⥒', r'⥓', r'⥖', r'⥗', r'⥚', r'⥛', r'⥞', r'⥟', r'⥢', r'⥤', r'⥦', r'⥧', r'⥨', r'⥩',
  38. r'⥪', r'⥫', r'⥬', r'⥭', r'⥰', r'⧴', r'⬱', r'⬰', r'⬲', r'⬳', r'⬴', r'⬵', r'⬶', r'⬷',
  39. r'⬸', r'⬹', r'⬺', r'⬻', r'⬼', r'⬽', r'⬾', r'⬿', r'⭀', r'⭁', r'⭂', r'⭃', r'⭄', r'⭇',
  40. r'⭈', r'⭉', r'⭊', r'⭋', r'⭌', r'←', r'→', r'⇜', r'⇝', r'↜', r'↝', r'↩', r'↪', r'↫',
  41. r'↬', r'↼', r'↽', r'⇀', r'⇁', r'⇄', r'⇆', r'⇇', r'⇉', r'⇋', r'⇌', r'⇚', r'⇛', r'⇠',
  42. r'⇢', r'↷', r'↶', r'↺', r'↻', r'-->', r'<--', r'<-->',
  43. # prec-comparison
  44. r'>', r'<', r'>=', r'≥', r'<=', r'≤', r'==', r'===', r'≡', r'!=', r'≠', r'!==',
  45. r'≢', r'∈', r'∉', r'∋', r'∌', r'⊆', r'⊈', r'⊂', r'⊄', r'⊊', r'∝', r'∊', r'∍', r'∥',
  46. r'∦', r'∷', r'∺', r'∻', r'∽', r'∾', r'≁', r'≃', r'≂', r'≄', r'≅', r'≆', r'≇', r'≈',
  47. r'≉', r'≊', r'≋', r'≌', r'≍', r'≎', r'≐', r'≑', r'≒', r'≓', r'≖', r'≗', r'≘', r'≙',
  48. r'≚', r'≛', r'≜', r'≝', r'≞', r'≟', r'≣', r'≦', r'≧', r'≨', r'≩', r'≪', r'≫', r'≬',
  49. r'≭', r'≮', r'≯', r'≰', r'≱', r'≲', r'≳', r'≴', r'≵', r'≶', r'≷', r'≸', r'≹', r'≺',
  50. r'≻', r'≼', r'≽', r'≾', r'≿', r'⊀', r'⊁', r'⊃', r'⊅', r'⊇', r'⊉', r'⊋', r'⊏', r'⊐',
  51. r'⊑', r'⊒', r'⊜', r'⊩', r'⊬', r'⊮', r'⊰', r'⊱', r'⊲', r'⊳', r'⊴', r'⊵', r'⊶', r'⊷',
  52. r'⋍', r'⋐', r'⋑', r'⋕', r'⋖', r'⋗', r'⋘', r'⋙', r'⋚', r'⋛', r'⋜', r'⋝', r'⋞', r'⋟',
  53. r'⋠', r'⋡', r'⋢', r'⋣', r'⋤', r'⋥', r'⋦', r'⋧', r'⋨', r'⋩', r'⋪', r'⋫', r'⋬', r'⋭',
  54. r'⋲', r'⋳', r'⋴', r'⋵', r'⋶', r'⋷', r'⋸', r'⋹', r'⋺', r'⋻', r'⋼', r'⋽', r'⋾', r'⋿',
  55. r'⟈', r'⟉', r'⟒', r'⦷', r'⧀', r'⧁', r'⧡', r'⧣', r'⧤', r'⧥', r'⩦', r'⩧', r'⩪', r'⩫',
  56. r'⩬', r'⩭', r'⩮', r'⩯', r'⩰', r'⩱', r'⩲', r'⩳', r'⩵', r'⩶', r'⩷', r'⩸', r'⩹', r'⩺',
  57. r'⩻', r'⩼', r'⩽', r'⩾', r'⩿', r'⪀', r'⪁', r'⪂', r'⪃', r'⪄', r'⪅', r'⪆', r'⪇', r'⪈',
  58. r'⪉', r'⪊', r'⪋', r'⪌', r'⪍', r'⪎', r'⪏', r'⪐', r'⪑', r'⪒', r'⪓', r'⪔', r'⪕', r'⪖',
  59. r'⪗', r'⪘', r'⪙', r'⪚', r'⪛', r'⪜', r'⪝', r'⪞', r'⪟', r'⪠', r'⪡', r'⪢', r'⪣', r'⪤',
  60. r'⪥', r'⪦', r'⪧', r'⪨', r'⪩', r'⪪', r'⪫', r'⪬', r'⪭', r'⪮', r'⪯', r'⪰', r'⪱', r'⪲',
  61. r'⪳', r'⪴', r'⪵', r'⪶', r'⪷', r'⪸', r'⪹', r'⪺', r'⪻', r'⪼', r'⪽', r'⪾', r'⪿', r'⫀',
  62. r'⫁', r'⫂', r'⫃', r'⫄', r'⫅', r'⫆', r'⫇', r'⫈', r'⫉', r'⫊', r'⫋', r'⫌', r'⫍', r'⫎',
  63. r'⫏', r'⫐', r'⫑', r'⫒', r'⫓', r'⫔', r'⫕', r'⫖', r'⫗', r'⫘', r'⫙', r'⫷', r'⫸', r'⫹',
  64. r'⫺', r'⊢', r'⊣', r'⟂', r'<:', r'>:',
  65. # prec-pipe
  66. '<|', '|>',
  67. # prec-colon
  68. r'…', r'⁝', r'⋮', r'⋱', r'⋰', r'⋯',
  69. # prec-plus
  70. r'+', r'-', r'¦', r'|', r'⊕', r'⊖', r'⊞', r'⊟', r'++', r'∪', r'∨', r'⊔', r'±', r'∓',
  71. r'∔', r'∸', r'≏', r'⊎', r'⊻', r'⊽', r'⋎', r'⋓', r'⧺', r'⧻', r'⨈', r'⨢', r'⨣', r'⨤',
  72. r'⨥', r'⨦', r'⨧', r'⨨', r'⨩', r'⨪', r'⨫', r'⨬', r'⨭', r'⨮', r'⨹', r'⨺', r'⩁', r'⩂',
  73. r'⩅', r'⩊', r'⩌', r'⩏', r'⩐', r'⩒', r'⩔', r'⩖', r'⩗', r'⩛', r'⩝', r'⩡', r'⩢', r'⩣',
  74. # prec-times
  75. r'*', r'/', r'⌿', r'÷', r'%', r'&', r'⋅', r'∘', r'×', '\\', r'∩', r'∧', r'⊗', r'⊘',
  76. r'⊙', r'⊚', r'⊛', r'⊠', r'⊡', r'⊓', r'∗', r'∙', r'∤', r'⅋', r'≀', r'⊼', r'⋄', r'⋆',
  77. r'⋇', r'⋉', r'⋊', r'⋋', r'⋌', r'⋏', r'⋒', r'⟑', r'⦸', r'⦼', r'⦾', r'⦿', r'⧶', r'⧷',
  78. r'⨇', r'⨰', r'⨱', r'⨲', r'⨳', r'⨴', r'⨵', r'⨶', r'⨷', r'⨸', r'⨻', r'⨼', r'⨽', r'⩀',
  79. r'⩃', r'⩄', r'⩋', r'⩍', r'⩎', r'⩑', r'⩓', r'⩕', r'⩘', r'⩚', r'⩜', r'⩞', r'⩟', r'⩠',
  80. r'⫛', r'⊍', r'▷', r'⨝', r'⟕', r'⟖', r'⟗', r'⨟',
  81. # prec-rational, prec-bitshift
  82. '//', '>>', '<<', '>>>',
  83. # prec-power
  84. r'^', r'↑', r'↓', r'⇵', r'⟰', r'⟱', r'⤈', r'⤉', r'⤊', r'⤋', r'⤒', r'⤓', r'⥉', r'⥌',
  85. r'⥍', r'⥏', r'⥑', r'⥔', r'⥕', r'⥘', r'⥙', r'⥜', r'⥝', r'⥠', r'⥡', r'⥣', r'⥥', r'⥮',
  86. r'⥯', r'↑', r'↓',
  87. # unary-ops, excluding unary-and-binary-ops
  88. '!', r'¬', r'√', r'∛', r'∜'
  89. ]
  90. # Generated with the following in Julia v1.6.0-rc1
  91. '''
  92. #!/usr/bin/env julia
  93. import REPL.REPLCompletions
  94. res = String["in", "isa", "where"]
  95. for kw in collect(x.keyword for x in REPLCompletions.complete_keyword(""))
  96. if !(contains(kw, " ") || kw == "struct")
  97. push!(res, kw)
  98. end
  99. end
  100. sort!(unique!(setdiff!(res, ["true", "false"])))
  101. foreach(x -> println("\'", x, "\',"), res)
  102. '''
  103. KEYWORD_LIST = (
  104. 'baremodule',
  105. 'begin',
  106. 'break',
  107. 'catch',
  108. 'ccall',
  109. 'const',
  110. 'continue',
  111. 'do',
  112. 'else',
  113. 'elseif',
  114. 'end',
  115. 'export',
  116. 'finally',
  117. 'for',
  118. 'function',
  119. 'global',
  120. 'if',
  121. 'import',
  122. 'in',
  123. 'isa',
  124. 'let',
  125. 'local',
  126. 'macro',
  127. 'module',
  128. 'quote',
  129. 'return',
  130. 'try',
  131. 'using',
  132. 'where',
  133. 'while',
  134. )
  135. # Generated with the following in Julia v1.6.0-rc1
  136. '''
  137. #!/usr/bin/env julia
  138. import REPL.REPLCompletions
  139. res = String[]
  140. for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
  141. REPLCompletions.completions("", 0)[1])
  142. try
  143. v = eval(Symbol(compl.mod))
  144. if (v isa Type || v isa TypeVar) && (compl.mod != "=>")
  145. push!(res, compl.mod)
  146. end
  147. catch e
  148. end
  149. end
  150. sort!(unique!(res))
  151. foreach(x -> println("\'", x, "\',"), res)
  152. '''
  153. BUILTIN_LIST = (
  154. 'AbstractArray',
  155. 'AbstractChannel',
  156. 'AbstractChar',
  157. 'AbstractDict',
  158. 'AbstractDisplay',
  159. 'AbstractFloat',
  160. 'AbstractIrrational',
  161. 'AbstractMatch',
  162. 'AbstractMatrix',
  163. 'AbstractPattern',
  164. 'AbstractRange',
  165. 'AbstractSet',
  166. 'AbstractString',
  167. 'AbstractUnitRange',
  168. 'AbstractVecOrMat',
  169. 'AbstractVector',
  170. 'Any',
  171. 'ArgumentError',
  172. 'Array',
  173. 'AssertionError',
  174. 'BigFloat',
  175. 'BigInt',
  176. 'BitArray',
  177. 'BitMatrix',
  178. 'BitSet',
  179. 'BitVector',
  180. 'Bool',
  181. 'BoundsError',
  182. 'CapturedException',
  183. 'CartesianIndex',
  184. 'CartesianIndices',
  185. 'Cchar',
  186. 'Cdouble',
  187. 'Cfloat',
  188. 'Channel',
  189. 'Char',
  190. 'Cint',
  191. 'Cintmax_t',
  192. 'Clong',
  193. 'Clonglong',
  194. 'Cmd',
  195. 'Colon',
  196. 'Complex',
  197. 'ComplexF16',
  198. 'ComplexF32',
  199. 'ComplexF64',
  200. 'ComposedFunction',
  201. 'CompositeException',
  202. 'Condition',
  203. 'Cptrdiff_t',
  204. 'Cshort',
  205. 'Csize_t',
  206. 'Cssize_t',
  207. 'Cstring',
  208. 'Cuchar',
  209. 'Cuint',
  210. 'Cuintmax_t',
  211. 'Culong',
  212. 'Culonglong',
  213. 'Cushort',
  214. 'Cvoid',
  215. 'Cwchar_t',
  216. 'Cwstring',
  217. 'DataType',
  218. 'DenseArray',
  219. 'DenseMatrix',
  220. 'DenseVecOrMat',
  221. 'DenseVector',
  222. 'Dict',
  223. 'DimensionMismatch',
  224. 'Dims',
  225. 'DivideError',
  226. 'DomainError',
  227. 'EOFError',
  228. 'Enum',
  229. 'ErrorException',
  230. 'Exception',
  231. 'ExponentialBackOff',
  232. 'Expr',
  233. 'Float16',
  234. 'Float32',
  235. 'Float64',
  236. 'Function',
  237. 'GlobalRef',
  238. 'HTML',
  239. 'IO',
  240. 'IOBuffer',
  241. 'IOContext',
  242. 'IOStream',
  243. 'IdDict',
  244. 'IndexCartesian',
  245. 'IndexLinear',
  246. 'IndexStyle',
  247. 'InexactError',
  248. 'InitError',
  249. 'Int',
  250. 'Int128',
  251. 'Int16',
  252. 'Int32',
  253. 'Int64',
  254. 'Int8',
  255. 'Integer',
  256. 'InterruptException',
  257. 'InvalidStateException',
  258. 'Irrational',
  259. 'KeyError',
  260. 'LinRange',
  261. 'LineNumberNode',
  262. 'LinearIndices',
  263. 'LoadError',
  264. 'MIME',
  265. 'Matrix',
  266. 'Method',
  267. 'MethodError',
  268. 'Missing',
  269. 'MissingException',
  270. 'Module',
  271. 'NTuple',
  272. 'NamedTuple',
  273. 'Nothing',
  274. 'Number',
  275. 'OrdinalRange',
  276. 'OutOfMemoryError',
  277. 'OverflowError',
  278. 'Pair',
  279. 'PartialQuickSort',
  280. 'PermutedDimsArray',
  281. 'Pipe',
  282. 'ProcessFailedException',
  283. 'Ptr',
  284. 'QuoteNode',
  285. 'Rational',
  286. 'RawFD',
  287. 'ReadOnlyMemoryError',
  288. 'Real',
  289. 'ReentrantLock',
  290. 'Ref',
  291. 'Regex',
  292. 'RegexMatch',
  293. 'RoundingMode',
  294. 'SegmentationFault',
  295. 'Set',
  296. 'Signed',
  297. 'Some',
  298. 'StackOverflowError',
  299. 'StepRange',
  300. 'StepRangeLen',
  301. 'StridedArray',
  302. 'StridedMatrix',
  303. 'StridedVecOrMat',
  304. 'StridedVector',
  305. 'String',
  306. 'StringIndexError',
  307. 'SubArray',
  308. 'SubString',
  309. 'SubstitutionString',
  310. 'Symbol',
  311. 'SystemError',
  312. 'Task',
  313. 'TaskFailedException',
  314. 'Text',
  315. 'TextDisplay',
  316. 'Timer',
  317. 'Tuple',
  318. 'Type',
  319. 'TypeError',
  320. 'TypeVar',
  321. 'UInt',
  322. 'UInt128',
  323. 'UInt16',
  324. 'UInt32',
  325. 'UInt64',
  326. 'UInt8',
  327. 'UndefInitializer',
  328. 'UndefKeywordError',
  329. 'UndefRefError',
  330. 'UndefVarError',
  331. 'Union',
  332. 'UnionAll',
  333. 'UnitRange',
  334. 'Unsigned',
  335. 'Val',
  336. 'Vararg',
  337. 'VecElement',
  338. 'VecOrMat',
  339. 'Vector',
  340. 'VersionNumber',
  341. 'WeakKeyDict',
  342. 'WeakRef',
  343. )
  344. # Generated with the following in Julia v1.6.0-rc1
  345. '''
  346. #!/usr/bin/env julia
  347. import REPL.REPLCompletions
  348. res = String["true", "false"]
  349. for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
  350. REPLCompletions.completions("", 0)[1])
  351. try
  352. v = eval(Symbol(compl.mod))
  353. if !(v isa Function || v isa Type || v isa TypeVar || v isa Module || v isa Colon)
  354. push!(res, compl.mod)
  355. end
  356. catch e
  357. end
  358. end
  359. sort!(unique!(res))
  360. foreach(x -> println("\'", x, "\',"), res)
  361. '''
  362. LITERAL_LIST = (
  363. 'ARGS',
  364. 'C_NULL',
  365. 'DEPOT_PATH',
  366. 'ENDIAN_BOM',
  367. 'ENV',
  368. 'Inf',
  369. 'Inf16',
  370. 'Inf32',
  371. 'Inf64',
  372. 'InsertionSort',
  373. 'LOAD_PATH',
  374. 'MergeSort',
  375. 'NaN',
  376. 'NaN16',
  377. 'NaN32',
  378. 'NaN64',
  379. 'PROGRAM_FILE',
  380. 'QuickSort',
  381. 'RoundDown',
  382. 'RoundFromZero',
  383. 'RoundNearest',
  384. 'RoundNearestTiesAway',
  385. 'RoundNearestTiesUp',
  386. 'RoundToZero',
  387. 'RoundUp',
  388. 'VERSION',
  389. 'devnull',
  390. 'false',
  391. 'im',
  392. 'missing',
  393. 'nothing',
  394. 'pi',
  395. 'stderr',
  396. 'stdin',
  397. 'stdout',
  398. 'true',
  399. 'undef',
  400. 'π',
  401. 'ℯ',
  402. )