applescript.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Language: AppleScript
  3. Authors: Nathan Grigg <[email protected]>, Dr. Drang <[email protected]>
  4. Category: scripting
  5. */
  6. function(hljs) {
  7. var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: ''});
  8. var PARAMS = {
  9. className: 'params',
  10. begin: '\\(', end: '\\)',
  11. contains: ['self', hljs.C_NUMBER_MODE, STRING]
  12. };
  13. var COMMENT_MODE_1 = hljs.COMMENT('--', '$');
  14. var COMMENT_MODE_2 = hljs.COMMENT(
  15. '\\(\\*',
  16. '\\*\\)',
  17. {
  18. contains: ['self', COMMENT_MODE_1] //allow nesting
  19. }
  20. );
  21. var COMMENTS = [
  22. COMMENT_MODE_1,
  23. COMMENT_MODE_2,
  24. hljs.HASH_COMMENT_MODE
  25. ];
  26. return {
  27. aliases: ['osascript'],
  28. keywords: {
  29. keyword:
  30. 'about above after against and around as at back before beginning ' +
  31. 'behind below beneath beside between but by considering ' +
  32. 'contain contains continue copy div does eighth else end equal ' +
  33. 'equals error every exit fifth first for fourth from front ' +
  34. 'get given global if ignoring in into is it its last local me ' +
  35. 'middle mod my ninth not of on onto or over prop property put ref ' +
  36. 'reference repeat returning script second set seventh since ' +
  37. 'sixth some tell tenth that the|0 then third through thru ' +
  38. 'timeout times to transaction try until where while whose with ' +
  39. 'without',
  40. literal:
  41. 'AppleScript false linefeed return pi quote result space tab true',
  42. built_in:
  43. 'alias application boolean class constant date file integer list ' +
  44. 'number real record string text ' +
  45. 'activate beep count delay launch log offset read round ' +
  46. 'run say summarize write ' +
  47. 'character characters contents day frontmost id item length ' +
  48. 'month name paragraph paragraphs rest reverse running time version ' +
  49. 'weekday word words year'
  50. },
  51. contains: [
  52. STRING,
  53. hljs.C_NUMBER_MODE,
  54. {
  55. className: 'built_in',
  56. begin:
  57. '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' +
  58. 'mount volume|path to|(close|open for) access|(get|set) eof|' +
  59. 'current date|do shell script|get volume settings|random number|' +
  60. 'set volume|system attribute|system info|time to GMT|' +
  61. '(load|run|store) script|scripting components|' +
  62. 'ASCII (character|number)|localized string|' +
  63. 'choose (application|color|file|file name|' +
  64. 'folder|from list|remote application|URL)|' +
  65. 'display (alert|dialog))\\b|^\\s*return\\b'
  66. },
  67. {
  68. className: 'literal',
  69. begin:
  70. '\\b(text item delimiters|current application|missing value)\\b'
  71. },
  72. {
  73. className: 'keyword',
  74. begin:
  75. '\\b(apart from|aside from|instead of|out of|greater than|' +
  76. "isn't|(doesn't|does not) (equal|come before|come after|contain)|" +
  77. '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' +
  78. 'contained by|comes (before|after)|a (ref|reference)|POSIX file|' +
  79. 'POSIX path|(date|time) string|quoted form)\\b'
  80. },
  81. {
  82. beginKeywords: 'on',
  83. illegal: '[${=;\\n]',
  84. contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS]
  85. }
  86. ].concat(COMMENTS),
  87. illegal: '//|->|=>|\\[\\['
  88. };
  89. }