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