prism-julia.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435
  1. Prism.languages.julia = {
  2. 'comment': {
  3. // support one level of nested comments
  4. // https://github.com/JuliaLang/julia/pull/6128
  5. pattern: /(^|[^\\])(?:#=(?:[^#=]|=(?!#)|#(?!=)|#=(?:[^#=]|=(?!#)|#(?!=))*=#)*=#|#.*)/,
  6. lookbehind: true
  7. },
  8. 'regex': {
  9. // https://docs.julialang.org/en/v1/manual/strings/#Regular-Expressions-1
  10. pattern: /r"(?:\\.|[^"\\\r\n])*"[imsx]{0,4}/,
  11. greedy: true
  12. },
  13. 'string': {
  14. // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
  15. // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
  16. // https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
  17. pattern: /"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|`(?:[^\\`\r\n]|\\.)*`/,
  18. greedy: true
  19. },
  20. 'char': {
  21. // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
  22. pattern: /(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'/,
  23. lookbehind: true,
  24. greedy: true
  25. },
  26. 'keyword': /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
  27. 'boolean': /\b(?:false|true)\b/,
  28. 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+(?:_[\da-f]+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[efp][+-]?\d+(?:_\d+)*)?j?/i,
  29. // https://docs.julialang.org/en/v1/manual/mathematical-operations/
  30. // https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity-1
  31. 'operator': /&&|\|\||[-+*^%÷⊻&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:|])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥'√∛]/,
  32. 'punctuation': /::?|[{}[\]();,.?]/,
  33. // https://docs.julialang.org/en/v1/base/numbers/#Base.im
  34. 'constant': /\b(?:(?:Inf|NaN)(?:16|32|64)?|im|pi)\b|[πℯ]/
  35. };