prism-mel.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Prism.languages.mel = {
  2. 'comment': {
  3. pattern: /\/\/.*|\/\*[\s\S]*?\*\//,
  4. greedy: true
  5. },
  6. 'code': {
  7. pattern: /`(?:\\.|[^\\`])*`/,
  8. greedy: true,
  9. alias: 'italic',
  10. inside: {
  11. 'delimiter': {
  12. pattern: /^`|`$/,
  13. alias: 'punctuation'
  14. },
  15. 'statement': {
  16. pattern: /[\s\S]+/,
  17. inside: null // see below
  18. }
  19. }
  20. },
  21. 'string': {
  22. pattern: /"(?:\\.|[^\\"\r\n])*"/,
  23. greedy: true
  24. },
  25. 'variable': /\$\w+/,
  26. 'number': /\b0x[\da-fA-F]+\b|\b\d+(?:\.\d*)?|\B\.\d+/,
  27. 'flag': {
  28. pattern: /-[^\d\W]\w*/,
  29. alias: 'operator'
  30. },
  31. 'keyword': /\b(?:break|case|continue|default|do|else|float|for|global|if|in|int|matrix|proc|return|string|switch|vector|while)\b/,
  32. 'function': {
  33. pattern: /((?:^|[{;])[ \t]*)[a-z_]\w*\b(?!\s*(?:\.(?!\.)|[[{=]))|\b[a-z_]\w*(?=[ \t]*\()/im,
  34. lookbehind: true,
  35. greedy: true
  36. },
  37. 'tensor-punctuation': {
  38. pattern: /<<|>>/,
  39. alias: 'punctuation'
  40. },
  41. 'operator': /\+[+=]?|-[-=]?|&&|\|\||[<>]=?|[*\/!=]=?|[%^]/,
  42. 'punctuation': /[.,:;?\[\](){}]/
  43. };
  44. Prism.languages.mel['code'].inside['statement'].inside = Prism.languages.mel;