javascript.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.highlight.languages.javascript"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.highlight.languages.javascript"] = true;
  8. dojo.provide("dojox.highlight.languages.javascript");
  9. dojo.require("dojox.highlight._base");
  10. (function(){
  11. var dh = dojox.highlight, dhc = dh.constants;
  12. dh.languages.javascript = {
  13. defaultMode: {
  14. lexems: [dhc.UNDERSCORE_IDENT_RE],
  15. contains: ['string', 'comment', 'number', 'regexp', 'function'],
  16. keywords: {
  17. 'keyword': {
  18. 'in': 1, 'if': 1, 'for': 1, 'while': 1, 'finally': 1, 'var': 1,
  19. 'new': 1, 'function': 1, 'do': 1, 'return': 1, 'void': 1,
  20. 'else': 1, 'break': 1, 'catch': 1, 'instanceof': 1, 'with': 1,
  21. 'throw': 1, 'case': 1, 'default': 1, 'try': 1, 'this': 1,
  22. 'switch': 1, 'continue': 1, 'typeof': 1, 'delete': 1
  23. },
  24. 'literal': {'true': 1, 'false': 1, 'null': 1}
  25. }
  26. },
  27. modes: [
  28. dhc.C_LINE_COMMENT_MODE,
  29. dhc.C_BLOCK_COMMENT_MODE,
  30. dhc.C_NUMBER_MODE,
  31. dhc.APOS_STRING_MODE,
  32. dhc.QUOTE_STRING_MODE,
  33. dhc.BACKSLASH_ESCAPE,
  34. {
  35. className: 'regexp',
  36. begin: '/.*?[^\\\\/]/[gim]*', end: '^'
  37. },
  38. {
  39. className: 'function',
  40. begin: 'function\\b', end: '{',
  41. lexems: [dhc.UNDERSCORE_IDENT_RE],
  42. keywords: {'function': 1},
  43. contains: ['title', 'params']
  44. },
  45. {
  46. className: 'title',
  47. begin: dhc.UNDERSCORE_IDENT_RE, end: '^'
  48. },
  49. {
  50. className: 'params',
  51. begin: '\\(', end: '\\)',
  52. contains: ['string', 'comment']
  53. }
  54. ]
  55. };
  56. })();
  57. }