prism-brightscript.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Prism.languages.brightscript = {
  2. 'comment': /(?:\brem|').*/i,
  3. 'directive-statement': {
  4. pattern: /(^[\t ]*)#(?:const|else(?:[\t ]+if)?|end[\t ]+if|error|if).*/im,
  5. lookbehind: true,
  6. alias: 'property',
  7. inside: {
  8. 'error-message': {
  9. pattern: /(^#error).+/,
  10. lookbehind: true
  11. },
  12. 'directive': {
  13. pattern: /^#(?:const|else(?:[\t ]+if)?|end[\t ]+if|error|if)/,
  14. alias: 'keyword'
  15. },
  16. 'expression': {
  17. pattern: /[\s\S]+/,
  18. inside: null // see below
  19. }
  20. }
  21. },
  22. 'property': {
  23. pattern: /([\r\n{,][\t ]*)(?:(?!\d)\w+|"(?:[^"\r\n]|"")*"(?!"))(?=[ \t]*:)/,
  24. lookbehind: true,
  25. greedy: true
  26. },
  27. 'string': {
  28. pattern: /"(?:[^"\r\n]|"")*"(?!")/,
  29. greedy: true
  30. },
  31. 'class-name': {
  32. pattern: /(\bAs[\t ]+)\w+/i,
  33. lookbehind: true
  34. },
  35. 'keyword': /\b(?:As|Dim|Each|Else|Elseif|End|Exit|For|Function|Goto|If|In|Print|Return|Step|Stop|Sub|Then|To|While)\b/i,
  36. 'boolean': /\b(?:false|true)\b/i,
  37. 'function': /\b(?!\d)\w+(?=[\t ]*\()/,
  38. 'number': /(?:\b\d+(?:\.\d+)?(?:[ed][+-]\d+)?|&h[a-f\d]+)\b[%&!#]?/i,
  39. 'operator': /--|\+\+|>>=?|<<=?|<>|[-+*/\\<>]=?|[:^=?]|\b(?:and|mod|not|or)\b/i,
  40. 'punctuation': /[.,;()[\]{}]/,
  41. 'constant': /\b(?:LINE_NUM)\b/i
  42. };
  43. Prism.languages.brightscript['directive-statement'].inside.expression.inside = Prism.languages.brightscript;