actionscript.js 2.1 KB

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