]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/applescript.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / applescript.js
1 /*! `applescript` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: AppleScript
7 Authors: Nathan Grigg <nathan@nathanamy.org>, Dr. Drang <drdrang@gmail.com>
8 Category: scripting
9 Website: https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html
10 Audit: 2020
11 */
12
13 /** @type LanguageFn */
14 function applescript(hljs) {
15 const regex = hljs.regex;
16 const STRING = hljs.inherit(
17 hljs.QUOTE_STRING_MODE, { illegal: null });
18 const PARAMS = {
19 className: 'params',
20 begin: /\(/,
21 end: /\)/,
22 contains: [
23 'self',
24 hljs.C_NUMBER_MODE,
25 STRING
26 ]
27 };
28 const COMMENT_MODE_1 = hljs.COMMENT(/--/, /$/);
29 const COMMENT_MODE_2 = hljs.COMMENT(
30 /\(\*/,
31 /\*\)/,
32 { contains: [
33 'self', // allow nesting
34 COMMENT_MODE_1
35 ] }
36 );
37 const COMMENTS = [
38 COMMENT_MODE_1,
39 COMMENT_MODE_2,
40 hljs.HASH_COMMENT_MODE
41 ];
42
43 const KEYWORD_PATTERNS = [
44 /apart from/,
45 /aside from/,
46 /instead of/,
47 /out of/,
48 /greater than/,
49 /isn't|(doesn't|does not) (equal|come before|come after|contain)/,
50 /(greater|less) than( or equal)?/,
51 /(starts?|ends|begins?) with/,
52 /contained by/,
53 /comes (before|after)/,
54 /a (ref|reference)/,
55 /POSIX (file|path)/,
56 /(date|time) string/,
57 /quoted form/
58 ];
59
60 const BUILT_IN_PATTERNS = [
61 /clipboard info/,
62 /the clipboard/,
63 /info for/,
64 /list (disks|folder)/,
65 /mount volume/,
66 /path to/,
67 /(close|open for) access/,
68 /(get|set) eof/,
69 /current date/,
70 /do shell script/,
71 /get volume settings/,
72 /random number/,
73 /set volume/,
74 /system attribute/,
75 /system info/,
76 /time to GMT/,
77 /(load|run|store) script/,
78 /scripting components/,
79 /ASCII (character|number)/,
80 /localized string/,
81 /choose (application|color|file|file name|folder|from list|remote application|URL)/,
82 /display (alert|dialog)/
83 ];
84
85 return {
86 name: 'AppleScript',
87 aliases: [ 'osascript' ],
88 keywords: {
89 keyword:
90 'about above after against and around as at back before beginning '
91 + 'behind below beneath beside between but by considering '
92 + 'contain contains continue copy div does eighth else end equal '
93 + 'equals error every exit fifth first for fourth from front '
94 + 'get given global if ignoring in into is it its last local me '
95 + 'middle mod my ninth not of on onto or over prop property put ref '
96 + 'reference repeat returning script second set seventh since '
97 + 'sixth some tell tenth that the|0 then third through thru '
98 + 'timeout times to transaction try until where while whose with '
99 + 'without',
100 literal:
101 'AppleScript false linefeed return pi quote result space tab true',
102 built_in:
103 'alias application boolean class constant date file integer list '
104 + 'number real record string text '
105 + 'activate beep count delay launch log offset read round '
106 + 'run say summarize write '
107 + 'character characters contents day frontmost id item length '
108 + 'month name|0 paragraph paragraphs rest reverse running time version '
109 + 'weekday word words year'
110 },
111 contains: [
112 STRING,
113 hljs.C_NUMBER_MODE,
114 {
115 className: 'built_in',
116 begin: regex.concat(
117 /\b/,
118 regex.either(...BUILT_IN_PATTERNS),
119 /\b/
120 )
121 },
122 {
123 className: 'built_in',
124 begin: /^\s*return\b/
125 },
126 {
127 className: 'literal',
128 begin:
129 /\b(text item delimiters|current application|missing value)\b/
130 },
131 {
132 className: 'keyword',
133 begin: regex.concat(
134 /\b/,
135 regex.either(...KEYWORD_PATTERNS),
136 /\b/
137 )
138 },
139 {
140 beginKeywords: 'on',
141 illegal: /[${=;\n]/,
142 contains: [
143 hljs.UNDERSCORE_TITLE_MODE,
144 PARAMS
145 ]
146 },
147 ...COMMENTS
148 ],
149 illegal: /\/\/|->|=>|\[\[/
150 };
151 }
152
153 return applescript;
154
155 })();
156 ;
157 export default hljsGrammar;