actionscript.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. module.exports = function(hljs) {
  2. var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
  3. var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';
  4. var AS3_REST_ARG_MODE = {
  5. className: 'rest_arg',
  6. begin: '[.]{3}', end: IDENT_RE,
  7. relevance: 10
  8. };
  9. return {
  10. aliases: ['as'],
  11. keywords: {
  12. keyword: 'as break case catch class const continue default delete do dynamic each ' +
  13. 'else extends final finally for function get if implements import in include ' +
  14. 'instanceof interface internal is namespace native new override package private ' +
  15. 'protected public return set static super switch this throw try typeof use var void ' +
  16. 'while with',
  17. literal: 'true false null undefined'
  18. },
  19. contains: [
  20. hljs.APOS_STRING_MODE,
  21. hljs.QUOTE_STRING_MODE,
  22. hljs.C_LINE_COMMENT_MODE,
  23. hljs.C_BLOCK_COMMENT_MODE,
  24. hljs.C_NUMBER_MODE,
  25. {
  26. className: 'class',
  27. beginKeywords: 'package', end: '{',
  28. contains: [hljs.TITLE_MODE]
  29. },
  30. {
  31. className: 'class',
  32. beginKeywords: 'class interface', end: '{', excludeEnd: true,
  33. contains: [
  34. {
  35. beginKeywords: 'extends implements'
  36. },
  37. hljs.TITLE_MODE
  38. ]
  39. },
  40. {
  41. className: 'meta',
  42. beginKeywords: 'import include', end: ';',
  43. keywords: {'meta-keyword': 'import include'}
  44. },
  45. {
  46. className: 'function',
  47. beginKeywords: 'function', end: '[{;]', excludeEnd: true,
  48. illegal: '\\S',
  49. contains: [
  50. hljs.TITLE_MODE,
  51. {
  52. className: 'params',
  53. begin: '\\(', end: '\\)',
  54. contains: [
  55. hljs.APOS_STRING_MODE,
  56. hljs.QUOTE_STRING_MODE,
  57. hljs.C_LINE_COMMENT_MODE,
  58. hljs.C_BLOCK_COMMENT_MODE,
  59. AS3_REST_ARG_MODE
  60. ]
  61. },
  62. {
  63. begin: ':\\s*' + IDENT_FUNC_RETURN_TYPE_RE
  64. }
  65. ]
  66. },
  67. hljs.METHOD_GUARD
  68. ],
  69. illegal: /#/
  70. };
  71. };