actionscript.js 2.2 KB

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