@univerjs/uniscript 0.3.0 → 0.4.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. package/lib/abap-BZS-1p12.js +6 -0
  2. package/lib/abap-D8H3nII2.mjs +1404 -0
  3. package/lib/apex-B2xdRF0k.js +6 -0
  4. package/lib/apex-BVHYDV51.mjs +334 -0
  5. package/lib/azcli-BwJ4gbR1.mjs +74 -0
  6. package/lib/azcli-CKk2q0zF.js +6 -0
  7. package/lib/bat-BDmMqWXx.mjs +106 -0
  8. package/lib/bat-Ehz5Z_mk.js +6 -0
  9. package/lib/bicep-B5L2IbSj.mjs +110 -0
  10. package/lib/bicep-WbLMPUMj.js +7 -0
  11. package/lib/cameligo-B_ldnAvM.js +6 -0
  12. package/lib/cameligo-CmyOPZUd.mjs +180 -0
  13. package/lib/cjs/index.js +1 -9
  14. package/lib/clojure-Dg-qgg-1.js +6 -0
  15. package/lib/clojure-iSXHsTlR.mjs +767 -0
  16. package/lib/coffee-BCg0pb49.js +6 -0
  17. package/lib/coffee-BUCk2FHC.mjs +238 -0
  18. package/lib/cpp-CJWZ7Zo7.js +6 -0
  19. package/lib/cpp-MUyeqRt5.mjs +395 -0
  20. package/lib/csharp-B9vyMfVU.mjs +332 -0
  21. package/lib/csharp-BZypj8XG.js +6 -0
  22. package/lib/csp-BfXxGnNN.js +6 -0
  23. package/lib/csp-CbylPXe5.mjs +59 -0
  24. package/lib/css-BPDnvT2s.js +8 -0
  25. package/lib/css-BQSMT8k7.mjs +193 -0
  26. package/lib/cssMode-B_of5tVd.js +9 -0
  27. package/lib/cssMode-BuX-eUHc.mjs +1604 -0
  28. package/lib/cypher-3bNWMNCJ.js +6 -0
  29. package/lib/cypher-D7IWy_82.mjs +269 -0
  30. package/lib/dart-BCVbUKaH.mjs +287 -0
  31. package/lib/dart-C9Glm5m-.js +6 -0
  32. package/lib/dockerfile-CjnlcV5o.js +6 -0
  33. package/lib/dockerfile-D2-hSnDX.mjs +136 -0
  34. package/lib/ecl-DRJlPmOb.mjs +462 -0
  35. package/lib/ecl-UyoSfv7F.js +6 -0
  36. package/lib/elixir-Bol0p0Ia.js +6 -0
  37. package/lib/elixir-D8NBXKCb.mjs +575 -0
  38. package/lib/es/index.js +5 -262
  39. package/lib/flow9-Be1OUdJl.js +6 -0
  40. package/lib/flow9-Dp7h8rKW.mjs +148 -0
  41. package/lib/freemarker2-D8-fH4uC.mjs +1001 -0
  42. package/lib/freemarker2-S5ay_GEf.js +8 -0
  43. package/lib/fsharp-CJxdVP7r.mjs +223 -0
  44. package/lib/fsharp-CKIYWNYJ.js +6 -0
  45. package/lib/go-DWj6zslQ.js +6 -0
  46. package/lib/go-IPaMO3Uz.mjs +224 -0
  47. package/lib/graphql-BzJpwfxN.js +6 -0
  48. package/lib/graphql-CMoDK5uf.mjs +157 -0
  49. package/lib/handlebars-CEMNnGaU.mjs +427 -0
  50. package/lib/handlebars-CM3PRDRO.js +6 -0
  51. package/lib/hcl-BCY6T0iq.js +6 -0
  52. package/lib/hcl-BTAYK4pT.mjs +189 -0
  53. package/lib/html-BSUn7oJR.mjs +316 -0
  54. package/lib/html-Df-Osxjs.js +6 -0
  55. package/lib/htmlMode-Bj4CfAzA.js +9 -0
  56. package/lib/htmlMode-xJPwX0cD.mjs +1615 -0
  57. package/lib/index-D6nY5NdF.mjs +116821 -0
  58. package/lib/index-rYV4VmC2.js +1163 -0
  59. package/lib/index.css +1 -1
  60. package/lib/ini-CC3_THb4.js +6 -0
  61. package/lib/ini-CiaphB6F.mjs +77 -0
  62. package/lib/java-CwRV8Dsg.js +6 -0
  63. package/lib/java-DxksziCw.mjs +238 -0
  64. package/lib/javascript-D1eKEotE.js +6 -0
  65. package/lib/javascript-c8D1_K05.mjs +76 -0
  66. package/lib/jsonMode-8-L3-E9k.mjs +2042 -0
  67. package/lib/jsonMode-BdBVsN9_.js +15 -0
  68. package/lib/julia-7Z1jwT4W.js +6 -0
  69. package/lib/julia-TTty8och.mjs +517 -0
  70. package/lib/kotlin-BAXgl2QX.js +6 -0
  71. package/lib/kotlin-Dzand-bM.mjs +259 -0
  72. package/lib/less-CSG9Zdoy.js +7 -0
  73. package/lib/less-CWDFQI_i.mjs +168 -0
  74. package/lib/lexon-BiTtMD9F.js +6 -0
  75. package/lib/lexon-bZpjZioh.mjs +163 -0
  76. package/lib/liquid-BmlJOXgY.js +6 -0
  77. package/lib/liquid-Bs7DM5cg.mjs +248 -0
  78. package/lib/locale/fa-IR.json +17 -0
  79. package/lib/lua-CoWYKXUu.mjs +168 -0
  80. package/lib/lua-o7UTFJ05.js +6 -0
  81. package/lib/m3-DIJY3uEe.mjs +216 -0
  82. package/lib/m3-DOYTRLxi.js +6 -0
  83. package/lib/markdown-CDlkMTMZ.mjs +235 -0
  84. package/lib/markdown-Di5faXtP.js +6 -0
  85. package/lib/mdx-BEI71kqO.mjs +173 -0
  86. package/lib/mdx-DJV2KJ98.js +6 -0
  87. package/lib/mips-CIiuS33B.mjs +204 -0
  88. package/lib/mips-CjGjcf9D.js +6 -0
  89. package/lib/msdax-4_jBeazN.mjs +381 -0
  90. package/lib/msdax-DZFpIwAH.js +6 -0
  91. package/lib/mysql-6Y0DL_eO.js +6 -0
  92. package/lib/mysql-D_KZRjSR.mjs +884 -0
  93. package/lib/objective-c-7nsY1fc1.mjs +189 -0
  94. package/lib/objective-c-BtrzMwBz.js +6 -0
  95. package/lib/pascal-BF06Dt9I.js +6 -0
  96. package/lib/pascal-BHpF9PW1.mjs +257 -0
  97. package/lib/pascaligo-BDrxVOcH.js +6 -0
  98. package/lib/pascaligo-C3mRbxmU.mjs +170 -0
  99. package/lib/perl-BMlqAyyD.js +6 -0
  100. package/lib/perl-F3tWDMLI.mjs +632 -0
  101. package/lib/pgsql-D62t1RD_.mjs +857 -0
  102. package/lib/pgsql-DXYBcnYD.js +6 -0
  103. package/lib/php-C8GGPjjI.mjs +506 -0
  104. package/lib/php-DmDmMNs3.js +6 -0
  105. package/lib/pla-2A6q3K8_.js +6 -0
  106. package/lib/pla-C_W_x2fV.mjs +143 -0
  107. package/lib/postiats-CMS8WwLg.mjs +913 -0
  108. package/lib/postiats-DQ-6iLGI.js +6 -0
  109. package/lib/powerquery-CuZPk7NC.js +6 -0
  110. package/lib/powerquery-Dcs0XplE.mjs +896 -0
  111. package/lib/powershell-Brx1N_3T.mjs +245 -0
  112. package/lib/powershell-D7BqJxnS.js +6 -0
  113. package/lib/protobuf-CkqkhuUG.js +7 -0
  114. package/lib/protobuf-UEJDuX6l.mjs +426 -0
  115. package/lib/pug-65DF18O8.js +6 -0
  116. package/lib/pug-LDwDmrMc.mjs +408 -0
  117. package/lib/python-BOeTitp9.mjs +309 -0
  118. package/lib/python-DRyE-VQQ.js +6 -0
  119. package/lib/qsharp-Cb7hPwnM.mjs +307 -0
  120. package/lib/qsharp-Dw07PXbd.js +6 -0
  121. package/lib/r-BHuY0po5.js +6 -0
  122. package/lib/r-BiFgSgcs.mjs +249 -0
  123. package/lib/razor-D0RPXCAO.mjs +558 -0
  124. package/lib/razor-DtDOotKq.js +6 -0
  125. package/lib/redis-BdzqoKC2.mjs +308 -0
  126. package/lib/redis-_Q4kv9ug.js +6 -0
  127. package/lib/redshift-DNNCHCLR.js +6 -0
  128. package/lib/redshift-Df6PoiEL.mjs +815 -0
  129. package/lib/restructuredtext-C9FM3r80.js +6 -0
  130. package/lib/restructuredtext-CW0ZtQ2l.mjs +180 -0
  131. package/lib/ruby-DyIFepcy.mjs +517 -0
  132. package/lib/ruby-DyJmXCYh.js +6 -0
  133. package/lib/rust-BiRHKB0S.mjs +349 -0
  134. package/lib/rust-DVvzZ_uH.js +6 -0
  135. package/lib/sb-CFwmZh3c.js +6 -0
  136. package/lib/sb-CahkGwPC.mjs +121 -0
  137. package/lib/scala-Cg9Wfw6B.mjs +376 -0
  138. package/lib/scala-DjaRe0PR.js +6 -0
  139. package/lib/scheme-Bqb0wlMX.mjs +114 -0
  140. package/lib/scheme-ZdeLzG0d.js +6 -0
  141. package/lib/scss-3qd2syug.mjs +268 -0
  142. package/lib/scss-Dqv1RljX.js +8 -0
  143. package/lib/shell-B5iW6U-v.mjs +227 -0
  144. package/lib/shell-BJ5zD_-e.js +6 -0
  145. package/lib/solidity-8Ys0iSgd.mjs +1373 -0
  146. package/lib/solidity-CagYWQAe.js +6 -0
  147. package/lib/sophia-PnZfErC3.mjs +205 -0
  148. package/lib/sophia-szuux90p.js +6 -0
  149. package/lib/sparql-CXz1-gkd.js +6 -0
  150. package/lib/sparql-CgWX-KRM.mjs +207 -0
  151. package/lib/sql-CN3Vg4Sm.mjs +859 -0
  152. package/lib/sql-CWZ5x4mg.js +6 -0
  153. package/lib/st-CcWMPoh3.js +6 -0
  154. package/lib/st-DKDuarOh.mjs +422 -0
  155. package/lib/swift-DUBoAkDR.js +8 -0
  156. package/lib/swift-DnXH6Con.mjs +318 -0
  157. package/lib/systemverilog-5hQzl-99.js +6 -0
  158. package/lib/systemverilog-pJOgZU46.mjs +582 -0
  159. package/lib/tcl-Bls9iNXn.mjs +238 -0
  160. package/lib/tcl-CiK0GhJi.js +6 -0
  161. package/lib/tsMode-BB2mDc5d.mjs +906 -0
  162. package/lib/tsMode-N-LS5RKx.js +16 -0
  163. package/lib/twig-B14HEeE0.mjs +398 -0
  164. package/lib/twig-Cbq-Ua-E.js +6 -0
  165. package/lib/types/locale/fa-IR.d.ts +3 -0
  166. package/lib/types/plugin.d.ts +2 -1
  167. package/lib/typescript-CZplv8KD.js +6 -0
  168. package/lib/typescript-f9PHTVoW.mjs +351 -0
  169. package/lib/typespec-Br_LC070.js +6 -0
  170. package/lib/typespec-dAaIdBal.mjs +125 -0
  171. package/lib/umd/index.js +1914 -2
  172. package/lib/vb-B1HzwoGL.js +6 -0
  173. package/lib/vb-CPBujGrP.mjs +378 -0
  174. package/lib/wgsl-BNAUPMiJ.js +303 -0
  175. package/lib/wgsl-CqCqdnZC.mjs +448 -0
  176. package/lib/xml-BSe-ETnG.js +6 -0
  177. package/lib/xml-Dv0cmUxw.mjs +103 -0
  178. package/lib/yaml-O_DoXtBP.js +6 -0
  179. package/lib/yaml-eXS7QSgG.mjs +214 -0
  180. package/package.json +13 -21
@@ -0,0 +1,575 @@
1
+ /*!-----------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Version: 0.52.0(f6dc0eb8fce67e57f6036f4769d92c1666cdf546)
4
+ * Released under the MIT license
5
+ * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
6
+ *-----------------------------------------------------------------------------*/
7
+ var conf = {
8
+ comments: {
9
+ lineComment: "#"
10
+ },
11
+ brackets: [
12
+ ["{", "}"],
13
+ ["[", "]"],
14
+ ["(", ")"]
15
+ ],
16
+ surroundingPairs: [
17
+ { open: "{", close: "}" },
18
+ { open: "[", close: "]" },
19
+ { open: "(", close: ")" },
20
+ { open: "'", close: "'" },
21
+ { open: '"', close: '"' }
22
+ ],
23
+ autoClosingPairs: [
24
+ { open: "'", close: "'", notIn: ["string", "comment"] },
25
+ { open: '"', close: '"', notIn: ["comment"] },
26
+ { open: '"""', close: '"""' },
27
+ { open: "`", close: "`", notIn: ["string", "comment"] },
28
+ { open: "(", close: ")" },
29
+ { open: "{", close: "}" },
30
+ { open: "[", close: "]" },
31
+ { open: "<<", close: ">>" }
32
+ ],
33
+ indentationRules: {
34
+ increaseIndentPattern: /^\s*(after|else|catch|rescue|fn|[^#]*(do|<\-|\->|\{|\[|\=))\s*$/,
35
+ decreaseIndentPattern: /^\s*((\}|\])\s*$|(after|else|catch|rescue|end)\b)/
36
+ }
37
+ }, language = {
38
+ defaultToken: "source",
39
+ tokenPostfix: ".elixir",
40
+ brackets: [
41
+ { open: "[", close: "]", token: "delimiter.square" },
42
+ { open: "(", close: ")", token: "delimiter.parenthesis" },
43
+ { open: "{", close: "}", token: "delimiter.curly" },
44
+ { open: "<<", close: ">>", token: "delimiter.angle.special" }
45
+ ],
46
+ // Below are lists/regexps to which we reference later.
47
+ declarationKeywords: [
48
+ "def",
49
+ "defp",
50
+ "defn",
51
+ "defnp",
52
+ "defguard",
53
+ "defguardp",
54
+ "defmacro",
55
+ "defmacrop",
56
+ "defdelegate",
57
+ "defcallback",
58
+ "defmacrocallback",
59
+ "defmodule",
60
+ "defprotocol",
61
+ "defexception",
62
+ "defimpl",
63
+ "defstruct"
64
+ ],
65
+ operatorKeywords: ["and", "in", "not", "or", "when"],
66
+ namespaceKeywords: ["alias", "import", "require", "use"],
67
+ otherKeywords: [
68
+ "after",
69
+ "case",
70
+ "catch",
71
+ "cond",
72
+ "do",
73
+ "else",
74
+ "end",
75
+ "fn",
76
+ "for",
77
+ "if",
78
+ "quote",
79
+ "raise",
80
+ "receive",
81
+ "rescue",
82
+ "super",
83
+ "throw",
84
+ "try",
85
+ "unless",
86
+ "unquote_splicing",
87
+ "unquote",
88
+ "with"
89
+ ],
90
+ constants: ["true", "false", "nil"],
91
+ nameBuiltin: ["__MODULE__", "__DIR__", "__ENV__", "__CALLER__", "__STACKTRACE__"],
92
+ // Matches any of the operator names:
93
+ // <<< >>> ||| &&& ^^^ ~~~ === !== ~>> <~> |~> <|> == != <= >= && || \\ <> ++ -- |> =~ -> <- ~> <~ :: .. = < > + - * / | . ^ & !
94
+ operator: /-[->]?|!={0,2}|\*{1,2}|\/|\\\\|&{1,3}|\.\.?|\^(?:\^\^)?|\+\+?|<(?:-|<<|=|>|\|>|~>?)?|=~|={1,3}|>(?:=|>>)?|\|~>|\|>|\|{1,3}|~>>?|~~~|::/,
95
+ // See https://hexdocs.pm/elixir/syntax-reference.html#variables
96
+ variableName: /[a-z_][a-zA-Z0-9_]*[?!]?/,
97
+ // See https://hexdocs.pm/elixir/syntax-reference.html#atoms
98
+ atomName: /[a-zA-Z_][a-zA-Z0-9_@]*[?!]?|@specialAtomName|@operator/,
99
+ specialAtomName: /\.\.\.|<<>>|%\{\}|%|\{\}/,
100
+ aliasPart: /[A-Z][a-zA-Z0-9_]*/,
101
+ moduleName: /@aliasPart(?:\.@aliasPart)*/,
102
+ // Sigil pairs are: """ """, ''' ''', " ", ' ', / /, | |, < >, { }, [ ], ( )
103
+ sigilSymmetricDelimiter: /"""|'''|"|'|\/|\|/,
104
+ sigilStartDelimiter: /@sigilSymmetricDelimiter|<|\{|\[|\(/,
105
+ sigilEndDelimiter: /@sigilSymmetricDelimiter|>|\}|\]|\)/,
106
+ sigilModifiers: /[a-zA-Z0-9]*/,
107
+ decimal: /\d(?:_?\d)*/,
108
+ hex: /[0-9a-fA-F](_?[0-9a-fA-F])*/,
109
+ octal: /[0-7](_?[0-7])*/,
110
+ binary: /[01](_?[01])*/,
111
+ // See https://hexdocs.pm/elixir/master/String.html#module-escape-characters
112
+ escape: /\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}|\\./,
113
+ // The keys below correspond to tokenizer states.
114
+ // We start from the root state and match against its rules
115
+ // until we explicitly transition into another state.
116
+ // The `include` simply brings in all operations from the given state
117
+ // and is useful for improving readability.
118
+ tokenizer: {
119
+ root: [
120
+ { include: "@whitespace" },
121
+ { include: "@comments" },
122
+ // Keywords start as either an identifier or a string,
123
+ // but end with a : so it's important to match this first.
124
+ { include: "@keywordsShorthand" },
125
+ { include: "@numbers" },
126
+ { include: "@identifiers" },
127
+ { include: "@strings" },
128
+ { include: "@atoms" },
129
+ { include: "@sigils" },
130
+ { include: "@attributes" },
131
+ { include: "@symbols" }
132
+ ],
133
+ // Whitespace
134
+ whitespace: [[/\s+/, "white"]],
135
+ // Comments
136
+ comments: [[/(#)(.*)/, ["comment.punctuation", "comment"]]],
137
+ // Keyword list shorthand
138
+ keywordsShorthand: [
139
+ [/(@atomName)(:)(\s+)/, ["constant", "constant.punctuation", "white"]],
140
+ // Use positive look-ahead to ensure the string is followed by :
141
+ // and should be considered a keyword.
142
+ [
143
+ /"(?=([^"]|#\{.*?\}|\\")*":)/,
144
+ { token: "constant.delimiter", next: "@doubleQuotedStringKeyword" }
145
+ ],
146
+ [
147
+ /'(?=([^']|#\{.*?\}|\\')*':)/,
148
+ { token: "constant.delimiter", next: "@singleQuotedStringKeyword" }
149
+ ]
150
+ ],
151
+ doubleQuotedStringKeyword: [
152
+ [/":/, { token: "constant.delimiter", next: "@pop" }],
153
+ { include: "@stringConstantContentInterpol" }
154
+ ],
155
+ singleQuotedStringKeyword: [
156
+ [/':/, { token: "constant.delimiter", next: "@pop" }],
157
+ { include: "@stringConstantContentInterpol" }
158
+ ],
159
+ // Numbers
160
+ numbers: [
161
+ [/0b@binary/, "number.binary"],
162
+ [/0o@octal/, "number.octal"],
163
+ [/0x@hex/, "number.hex"],
164
+ [/@decimal\.@decimal([eE]-?@decimal)?/, "number.float"],
165
+ [/@decimal/, "number"]
166
+ ],
167
+ // Identifiers
168
+ identifiers: [
169
+ // Tokenize identifier name in function-like definitions.
170
+ // Note: given `def a + b, do: nil`, `a` is not a function name,
171
+ // so we use negative look-ahead to ensure there's no operator.
172
+ [
173
+ /\b(defp?|defnp?|defmacrop?|defguardp?|defdelegate)(\s+)(@variableName)(?!\s+@operator)/,
174
+ [
175
+ "keyword.declaration",
176
+ "white",
177
+ {
178
+ cases: {
179
+ unquote: "keyword",
180
+ "@default": "function"
181
+ }
182
+ }
183
+ ]
184
+ ],
185
+ // Tokenize function calls
186
+ [
187
+ // In-scope call - an identifier followed by ( or .(
188
+ /(@variableName)(?=\s*\.?\s*\()/,
189
+ {
190
+ cases: {
191
+ // Tokenize as keyword in cases like `if(..., do: ..., else: ...)`
192
+ "@declarationKeywords": "keyword.declaration",
193
+ "@namespaceKeywords": "keyword",
194
+ "@otherKeywords": "keyword",
195
+ "@default": "function.call"
196
+ }
197
+ }
198
+ ],
199
+ [
200
+ // Referencing function in a module
201
+ /(@moduleName)(\s*)(\.)(\s*)(@variableName)/,
202
+ ["type.identifier", "white", "operator", "white", "function.call"]
203
+ ],
204
+ [
205
+ // Referencing function in an Erlang module
206
+ /(:)(@atomName)(\s*)(\.)(\s*)(@variableName)/,
207
+ ["constant.punctuation", "constant", "white", "operator", "white", "function.call"]
208
+ ],
209
+ [
210
+ // Piping into a function (tokenized separately as it may not have parentheses)
211
+ /(\|>)(\s*)(@variableName)/,
212
+ [
213
+ "operator",
214
+ "white",
215
+ {
216
+ cases: {
217
+ "@otherKeywords": "keyword",
218
+ "@default": "function.call"
219
+ }
220
+ }
221
+ ]
222
+ ],
223
+ [
224
+ // Function reference passed to another function
225
+ /(&)(\s*)(@variableName)/,
226
+ ["operator", "white", "function.call"]
227
+ ],
228
+ // Language keywords, builtins, constants and variables
229
+ [
230
+ /@variableName/,
231
+ {
232
+ cases: {
233
+ "@declarationKeywords": "keyword.declaration",
234
+ "@operatorKeywords": "keyword.operator",
235
+ "@namespaceKeywords": "keyword",
236
+ "@otherKeywords": "keyword",
237
+ "@constants": "constant.language",
238
+ "@nameBuiltin": "variable.language",
239
+ "_.*": "comment.unused",
240
+ "@default": "identifier"
241
+ }
242
+ }
243
+ ],
244
+ // Module names
245
+ [/@moduleName/, "type.identifier"]
246
+ ],
247
+ // Strings
248
+ strings: [
249
+ [/"""/, { token: "string.delimiter", next: "@doubleQuotedHeredoc" }],
250
+ [/'''/, { token: "string.delimiter", next: "@singleQuotedHeredoc" }],
251
+ [/"/, { token: "string.delimiter", next: "@doubleQuotedString" }],
252
+ [/'/, { token: "string.delimiter", next: "@singleQuotedString" }]
253
+ ],
254
+ doubleQuotedHeredoc: [
255
+ [/"""/, { token: "string.delimiter", next: "@pop" }],
256
+ { include: "@stringContentInterpol" }
257
+ ],
258
+ singleQuotedHeredoc: [
259
+ [/'''/, { token: "string.delimiter", next: "@pop" }],
260
+ { include: "@stringContentInterpol" }
261
+ ],
262
+ doubleQuotedString: [
263
+ [/"/, { token: "string.delimiter", next: "@pop" }],
264
+ { include: "@stringContentInterpol" }
265
+ ],
266
+ singleQuotedString: [
267
+ [/'/, { token: "string.delimiter", next: "@pop" }],
268
+ { include: "@stringContentInterpol" }
269
+ ],
270
+ // Atoms
271
+ atoms: [
272
+ [/(:)(@atomName)/, ["constant.punctuation", "constant"]],
273
+ [/:"/, { token: "constant.delimiter", next: "@doubleQuotedStringAtom" }],
274
+ [/:'/, { token: "constant.delimiter", next: "@singleQuotedStringAtom" }]
275
+ ],
276
+ doubleQuotedStringAtom: [
277
+ [/"/, { token: "constant.delimiter", next: "@pop" }],
278
+ { include: "@stringConstantContentInterpol" }
279
+ ],
280
+ singleQuotedStringAtom: [
281
+ [/'/, { token: "constant.delimiter", next: "@pop" }],
282
+ { include: "@stringConstantContentInterpol" }
283
+ ],
284
+ // Sigils
285
+ // See https://elixir-lang.org/getting-started/sigils.html
286
+ // Sigils allow for typing values using their textual representation.
287
+ // All sigils start with ~ followed by a letter or
288
+ // multi-letter uppercase starting at Elixir v1.15.0, indicating sigil type
289
+ // and then a delimiter pair enclosing the textual representation.
290
+ // Optional modifiers are allowed after the closing delimiter.
291
+ // For instance a regular expressions can be written as:
292
+ // ~r/foo|bar/ ~r{foo|bar} ~r/foo|bar/g
293
+ //
294
+ // In general lowercase sigils allow for interpolation
295
+ // and escaped characters, whereas uppercase sigils don't
296
+ //
297
+ // During tokenization we want to distinguish some
298
+ // specific sigil types, namely string and regexp,
299
+ // so that they cen be themed separately.
300
+ //
301
+ // To reasonably handle all those combinations we leverage
302
+ // dot-separated states, so if we transition to @sigilStart.interpol.s.{.}
303
+ // then "sigilStart.interpol.s" state will match and also all
304
+ // the individual dot-separated parameters can be accessed.
305
+ sigils: [
306
+ [/~[a-z]@sigilStartDelimiter/, { token: "@rematch", next: "@sigil.interpol" }],
307
+ [/~([A-Z]+)@sigilStartDelimiter/, { token: "@rematch", next: "@sigil.noInterpol" }]
308
+ ],
309
+ sigil: [
310
+ [/~([a-z]|[A-Z]+)\{/, { token: "@rematch", switchTo: "@sigilStart.$S2.$1.{.}" }],
311
+ [/~([a-z]|[A-Z]+)\[/, { token: "@rematch", switchTo: "@sigilStart.$S2.$1.[.]" }],
312
+ [/~([a-z]|[A-Z]+)\(/, { token: "@rematch", switchTo: "@sigilStart.$S2.$1.(.)" }],
313
+ [/~([a-z]|[A-Z]+)\</, { token: "@rematch", switchTo: "@sigilStart.$S2.$1.<.>" }],
314
+ [
315
+ /~([a-z]|[A-Z]+)(@sigilSymmetricDelimiter)/,
316
+ { token: "@rematch", switchTo: "@sigilStart.$S2.$1.$2.$2" }
317
+ ]
318
+ ],
319
+ // The definitions below expect states to be of the form:
320
+ //
321
+ // sigilStart.<interpol-or-noInterpol>.<sigil-letter>.<start-delimiter>.<end-delimiter>
322
+ // sigilContinue.<interpol-or-noInterpol>.<sigil-letter>.<start-delimiter>.<end-delimiter>
323
+ //
324
+ // The sigilStart state is used only to properly classify the token (as string/regex/sigil)
325
+ // and immediately switches to the sigilContinue sate, which handles the actual content
326
+ // and waits for the corresponding end delimiter.
327
+ "sigilStart.interpol.s": [
328
+ [
329
+ /~s@sigilStartDelimiter/,
330
+ {
331
+ token: "string.delimiter",
332
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
333
+ }
334
+ ]
335
+ ],
336
+ "sigilContinue.interpol.s": [
337
+ [
338
+ /(@sigilEndDelimiter)@sigilModifiers/,
339
+ {
340
+ cases: {
341
+ "$1==$S5": { token: "string.delimiter", next: "@pop" },
342
+ "@default": "string"
343
+ }
344
+ }
345
+ ],
346
+ { include: "@stringContentInterpol" }
347
+ ],
348
+ "sigilStart.noInterpol.S": [
349
+ [
350
+ /~S@sigilStartDelimiter/,
351
+ {
352
+ token: "string.delimiter",
353
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
354
+ }
355
+ ]
356
+ ],
357
+ "sigilContinue.noInterpol.S": [
358
+ // Ignore escaped sigil end
359
+ [/(^|[^\\])\\@sigilEndDelimiter/, "string"],
360
+ [
361
+ /(@sigilEndDelimiter)@sigilModifiers/,
362
+ {
363
+ cases: {
364
+ "$1==$S5": { token: "string.delimiter", next: "@pop" },
365
+ "@default": "string"
366
+ }
367
+ }
368
+ ],
369
+ { include: "@stringContent" }
370
+ ],
371
+ "sigilStart.interpol.r": [
372
+ [
373
+ /~r@sigilStartDelimiter/,
374
+ {
375
+ token: "regexp.delimiter",
376
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
377
+ }
378
+ ]
379
+ ],
380
+ "sigilContinue.interpol.r": [
381
+ [
382
+ /(@sigilEndDelimiter)@sigilModifiers/,
383
+ {
384
+ cases: {
385
+ "$1==$S5": { token: "regexp.delimiter", next: "@pop" },
386
+ "@default": "regexp"
387
+ }
388
+ }
389
+ ],
390
+ { include: "@regexpContentInterpol" }
391
+ ],
392
+ "sigilStart.noInterpol.R": [
393
+ [
394
+ /~R@sigilStartDelimiter/,
395
+ {
396
+ token: "regexp.delimiter",
397
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
398
+ }
399
+ ]
400
+ ],
401
+ "sigilContinue.noInterpol.R": [
402
+ // Ignore escaped sigil end
403
+ [/(^|[^\\])\\@sigilEndDelimiter/, "regexp"],
404
+ [
405
+ /(@sigilEndDelimiter)@sigilModifiers/,
406
+ {
407
+ cases: {
408
+ "$1==$S5": { token: "regexp.delimiter", next: "@pop" },
409
+ "@default": "regexp"
410
+ }
411
+ }
412
+ ],
413
+ { include: "@regexpContent" }
414
+ ],
415
+ // Fallback to the generic sigil by default
416
+ "sigilStart.interpol": [
417
+ [
418
+ /~([a-z]|[A-Z]+)@sigilStartDelimiter/,
419
+ {
420
+ token: "sigil.delimiter",
421
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
422
+ }
423
+ ]
424
+ ],
425
+ "sigilContinue.interpol": [
426
+ [
427
+ /(@sigilEndDelimiter)@sigilModifiers/,
428
+ {
429
+ cases: {
430
+ "$1==$S5": { token: "sigil.delimiter", next: "@pop" },
431
+ "@default": "sigil"
432
+ }
433
+ }
434
+ ],
435
+ { include: "@sigilContentInterpol" }
436
+ ],
437
+ "sigilStart.noInterpol": [
438
+ [
439
+ /~([a-z]|[A-Z]+)@sigilStartDelimiter/,
440
+ {
441
+ token: "sigil.delimiter",
442
+ switchTo: "@sigilContinue.$S2.$S3.$S4.$S5"
443
+ }
444
+ ]
445
+ ],
446
+ "sigilContinue.noInterpol": [
447
+ // Ignore escaped sigil end
448
+ [/(^|[^\\])\\@sigilEndDelimiter/, "sigil"],
449
+ [
450
+ /(@sigilEndDelimiter)@sigilModifiers/,
451
+ {
452
+ cases: {
453
+ "$1==$S5": { token: "sigil.delimiter", next: "@pop" },
454
+ "@default": "sigil"
455
+ }
456
+ }
457
+ ],
458
+ { include: "@sigilContent" }
459
+ ],
460
+ // Attributes
461
+ attributes: [
462
+ // Module @doc* attributes - tokenized as comments
463
+ [
464
+ /\@(module|type)?doc (~[sS])?"""/,
465
+ {
466
+ token: "comment.block.documentation",
467
+ next: "@doubleQuotedHeredocDocstring"
468
+ }
469
+ ],
470
+ [
471
+ /\@(module|type)?doc (~[sS])?'''/,
472
+ {
473
+ token: "comment.block.documentation",
474
+ next: "@singleQuotedHeredocDocstring"
475
+ }
476
+ ],
477
+ [
478
+ /\@(module|type)?doc (~[sS])?"/,
479
+ {
480
+ token: "comment.block.documentation",
481
+ next: "@doubleQuotedStringDocstring"
482
+ }
483
+ ],
484
+ [
485
+ /\@(module|type)?doc (~[sS])?'/,
486
+ {
487
+ token: "comment.block.documentation",
488
+ next: "@singleQuotedStringDocstring"
489
+ }
490
+ ],
491
+ [/\@(module|type)?doc false/, "comment.block.documentation"],
492
+ // Module attributes
493
+ [/\@(@variableName)/, "variable"]
494
+ ],
495
+ doubleQuotedHeredocDocstring: [
496
+ [/"""/, { token: "comment.block.documentation", next: "@pop" }],
497
+ { include: "@docstringContent" }
498
+ ],
499
+ singleQuotedHeredocDocstring: [
500
+ [/'''/, { token: "comment.block.documentation", next: "@pop" }],
501
+ { include: "@docstringContent" }
502
+ ],
503
+ doubleQuotedStringDocstring: [
504
+ [/"/, { token: "comment.block.documentation", next: "@pop" }],
505
+ { include: "@docstringContent" }
506
+ ],
507
+ singleQuotedStringDocstring: [
508
+ [/'/, { token: "comment.block.documentation", next: "@pop" }],
509
+ { include: "@docstringContent" }
510
+ ],
511
+ // Operators, punctuation, brackets
512
+ symbols: [
513
+ // Code point operator (either with regular character ?a or an escaped one ?\n)
514
+ [/\?(\\.|[^\\\s])/, "number.constant"],
515
+ // Anonymous function arguments
516
+ [/&\d+/, "operator"],
517
+ // Bitshift operators (must go before delimiters, so that << >> don't match first)
518
+ [/<<<|>>>/, "operator"],
519
+ // Delimiter pairs
520
+ [/[()\[\]\{\}]|<<|>>/, "@brackets"],
521
+ // Triple dot is a valid name (must go before operators, so that .. doesn't match instead)
522
+ [/\.\.\./, "identifier"],
523
+ // Punctuation => (must go before operators, so it's not tokenized as = then >)
524
+ [/=>/, "punctuation"],
525
+ // Operators
526
+ [/@operator/, "operator"],
527
+ // Punctuation
528
+ [/[:;,.%]/, "punctuation"]
529
+ ],
530
+ // Generic helpers
531
+ stringContentInterpol: [
532
+ { include: "@interpolation" },
533
+ { include: "@escapeChar" },
534
+ { include: "@stringContent" }
535
+ ],
536
+ stringContent: [[/./, "string"]],
537
+ stringConstantContentInterpol: [
538
+ { include: "@interpolation" },
539
+ { include: "@escapeChar" },
540
+ { include: "@stringConstantContent" }
541
+ ],
542
+ stringConstantContent: [[/./, "constant"]],
543
+ regexpContentInterpol: [
544
+ { include: "@interpolation" },
545
+ { include: "@escapeChar" },
546
+ { include: "@regexpContent" }
547
+ ],
548
+ regexpContent: [
549
+ // # may be a regular regexp char, so we use a heuristic
550
+ // assuming a # surrounded by whitespace is actually a comment.
551
+ [/(\s)(#)(\s.*)$/, ["white", "comment.punctuation", "comment"]],
552
+ [/./, "regexp"]
553
+ ],
554
+ sigilContentInterpol: [
555
+ { include: "@interpolation" },
556
+ { include: "@escapeChar" },
557
+ { include: "@sigilContent" }
558
+ ],
559
+ sigilContent: [[/./, "sigil"]],
560
+ docstringContent: [[/./, "comment.block.documentation"]],
561
+ escapeChar: [[/@escape/, "constant.character.escape"]],
562
+ interpolation: [[/#{/, { token: "delimiter.bracket.embed", next: "@interpolationContinue" }]],
563
+ interpolationContinue: [
564
+ [/}/, { token: "delimiter.bracket.embed", next: "@pop" }],
565
+ // Interpolation brackets may contain arbitrary code,
566
+ // so we simply match against all the root rules,
567
+ // until we reach interpolation end (the above matches).
568
+ { include: "@root" }
569
+ ]
570
+ }
571
+ };
572
+ export {
573
+ conf,
574
+ language
575
+ };