prism-odin.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. (function (Prism) {
  2. var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/;
  3. Prism.languages.odin = {
  4. /**
  5. * The current implementation supports only 1 level of nesting.
  6. *
  7. * @author Michael Schmidt
  8. * @author edukisto
  9. */
  10. 'comment': [
  11. {
  12. pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,
  13. greedy: true
  14. },
  15. {
  16. pattern: /#![^\n\r]*/,
  17. greedy: true
  18. },
  19. {
  20. pattern: /\/\/[^\n\r]*/,
  21. greedy: true
  22. }
  23. ],
  24. /**
  25. * Should be found before strings because of '"'"- and '`'`-like sequences.
  26. */
  27. 'char': {
  28. pattern: /'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/,
  29. greedy: true,
  30. inside: {
  31. 'symbol': escapes
  32. }
  33. },
  34. 'string': [
  35. {
  36. pattern: /`[^`]*`/,
  37. greedy: true
  38. },
  39. {
  40. pattern: /"(?:\\.|[^\n\r"\\])*"/,
  41. greedy: true,
  42. inside: {
  43. 'symbol': escapes
  44. }
  45. }
  46. ],
  47. 'directive': {
  48. pattern: /#\w+/,
  49. alias: 'property'
  50. },
  51. 'number': /\b0(?:b[01_]+|d[\d_]+|h_*(?:(?:(?:[\dA-Fa-f]_*){8}){1,2}|(?:[\dA-Fa-f]_*){4})|o[0-7_]+|x[\dA-F_a-f]+|z[\dAB_ab]+)\b|(?:\b\d+(?:\.(?!\.)\d*)?|\B\.\d+)(?:[Ee][+-]?\d*)?[ijk]?(?!\w)/,
  52. 'discard': {
  53. pattern: /\b_\b/,
  54. alias: 'keyword'
  55. },
  56. 'procedure-definition': {
  57. pattern: /\b\w+(?=[ \t]*(?::\s*){2}proc\b)/,
  58. alias: 'function'
  59. },
  60. 'keyword': /\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|proc|return|struct|switch|transmute|typeid|union|using|when|where)\b/,
  61. /**
  62. * false, nil, true can be used as procedure names. "_" and keywords can't.
  63. */
  64. 'procedure-name': {
  65. pattern: /\b\w+(?=[ \t]*\()/,
  66. alias: 'function'
  67. },
  68. 'boolean': /\b(?:false|nil|true)\b/,
  69. 'constant-parameter-sign': {
  70. pattern: /\$/,
  71. alias: 'important'
  72. },
  73. 'undefined': {
  74. pattern: /---/,
  75. alias: 'operator'
  76. },
  77. 'arrow': {
  78. pattern: /->/,
  79. alias: 'punctuation'
  80. },
  81. 'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,
  82. 'punctuation': /[(),.:;@\[\]{}]/
  83. };
  84. }(Prism));