prism-cfscript.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // https://cfdocs.org/script
  2. Prism.languages.cfscript = Prism.languages.extend('clike', {
  3. 'comment': [
  4. {
  5. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  6. lookbehind: true,
  7. inside: {
  8. 'annotation': {
  9. pattern: /(?:^|[^.])@[\w\.]+/,
  10. alias: 'punctuation'
  11. }
  12. }
  13. },
  14. {
  15. pattern: /(^|[^\\:])\/\/.*/,
  16. lookbehind: true,
  17. greedy: true
  18. }
  19. ],
  20. 'keyword': /\b(?:abstract|break|catch|component|continue|default|do|else|extends|final|finally|for|function|if|in|include|package|private|property|public|remote|required|rethrow|return|static|switch|throw|try|var|while|xml)\b(?!\s*=)/,
  21. 'operator': [
  22. /\+\+|--|&&|\|\||::|=>|[!=]==|[-+*/%&|^!=<>]=?|\?(?:\.|:)?|:/,
  23. /\b(?:and|contains|eq|equal|eqv|gt|gte|imp|is|lt|lte|mod|not|or|xor)\b/
  24. ],
  25. 'scope': {
  26. pattern: /\b(?:application|arguments|cgi|client|cookie|local|session|super|this|variables)\b/,
  27. alias: 'global'
  28. },
  29. 'type': {
  30. pattern: /\b(?:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid|void|xml)\b/,
  31. alias: 'builtin'
  32. }
  33. });
  34. Prism.languages.insertBefore('cfscript', 'keyword', {
  35. // This must be declared before keyword because we use "function" inside the lookahead
  36. 'function-variable': {
  37. pattern: /[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
  38. alias: 'function'
  39. }
  40. });
  41. delete Prism.languages.cfscript['class-name'];
  42. Prism.languages.cfc = Prism.languages['cfscript'];