prism-maxscript.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. (function (Prism) {
  2. var keywords = /\b(?:about|and|animate|as|at|attributes|by|case|catch|collect|continue|coordsys|do|else|exit|fn|for|from|function|global|if|in|local|macroscript|mapped|max|not|of|off|on|or|parameters|persistent|plugin|rcmenu|return|rollout|set|struct|then|throw|to|tool|try|undo|utility|when|where|while|with)\b/i;
  3. Prism.languages.maxscript = {
  4. 'comment': {
  5. pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/,
  6. greedy: true
  7. },
  8. 'string': {
  9. pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/,
  10. lookbehind: true,
  11. greedy: true
  12. },
  13. 'path': {
  14. pattern: /\$(?:[\w/\\.*?]|'[^']*')*/,
  15. greedy: true,
  16. alias: 'string'
  17. },
  18. 'function-call': {
  19. pattern: RegExp(
  20. '((?:' + (
  21. // start of line
  22. /^/.source +
  23. '|' +
  24. // operators and other language constructs
  25. /[;=<>+\-*/^({\[]/.source +
  26. '|' +
  27. // keywords as part of statements
  28. /\b(?:and|by|case|catch|collect|do|else|if|in|not|or|return|then|to|try|where|while|with)\b/.source
  29. ) + ')[ \t]*)' +
  30. '(?!' + keywords.source + ')' + /[a-z_]\w*\b/.source +
  31. '(?=[ \t]*(?:' + (
  32. // variable
  33. '(?!' + keywords.source + ')' + /[a-z_]/.source +
  34. '|' +
  35. // number
  36. /\d|-\.?\d/.source +
  37. '|' +
  38. // other expressions or literals
  39. /[({'"$@#?]/.source
  40. ) + '))',
  41. 'im'
  42. ),
  43. lookbehind: true,
  44. greedy: true,
  45. alias: 'function'
  46. },
  47. 'function-definition': {
  48. pattern: /(\b(?:fn|function)\s+)\w+\b/i,
  49. lookbehind: true,
  50. alias: 'function'
  51. },
  52. 'argument': {
  53. pattern: /\b[a-z_]\w*(?=:)/i,
  54. alias: 'attr-name'
  55. },
  56. 'keyword': keywords,
  57. 'boolean': /\b(?:false|true)\b/,
  58. 'time': {
  59. pattern: /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/,
  60. lookbehind: true,
  61. alias: 'number'
  62. },
  63. 'number': [
  64. {
  65. pattern: /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/,
  66. lookbehind: true
  67. },
  68. /\b(?:e|pi)\b/
  69. ],
  70. 'constant': /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/,
  71. 'color': {
  72. pattern: /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/i,
  73. alias: 'constant'
  74. },
  75. 'operator': /[-+*/<>=!]=?|[&^?]|#(?!\()/,
  76. 'punctuation': /[()\[\]{}.:,;]|#(?=\()|\\$/m
  77. };
  78. }(Prism));