applescript.js 3.2 KB

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