@vc-shell/framework 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/apl-B2DGVGxc.js +76 -0
  3. package/dist/asciiarmor-2LVJmxlE.js +34 -0
  4. package/dist/asn1-jKiBa2Ya.js +95 -0
  5. package/dist/asterisk-DS281yxp.js +271 -0
  6. package/dist/brainfuck-C_p9pTT8.js +34 -0
  7. package/dist/clike-BUuHEmgZ.js +620 -0
  8. package/dist/clojure-CCKyeQKf.js +800 -0
  9. package/dist/cmake-CuaCgAKt.js +28 -0
  10. package/dist/cobol-BlTKFDRj.js +72 -0
  11. package/dist/coffeescript-BVCvwO8I.js +179 -0
  12. package/dist/commonlisp-D_kxz07b.js +75 -0
  13. package/dist/crystal-D309uH6_.js +217 -0
  14. package/dist/css-bIlmDBTK.js +1560 -0
  15. package/dist/cypher-BMq4Fwjl.js +68 -0
  16. package/dist/d-BZcgY6La.js +127 -0
  17. package/dist/diff-Cg9d_RX2.js +18 -0
  18. package/dist/{assets/dockerfile-D0MivFIF.js → dockerfile-DIy8NleC.js} +36 -41
  19. package/dist/dtd-CtLokQ-U.js +84 -0
  20. package/dist/dylan-QYeExnWK.js +234 -0
  21. package/dist/ebnf-DUPDuY4r.js +78 -0
  22. package/dist/ecl-CiXN-g_D.js +121 -0
  23. package/dist/eiffel-yQhjl4T1.js +110 -0
  24. package/dist/elm-CNT9vbN0.js +108 -0
  25. package/dist/erlang-CFOYdy9e.js +487 -0
  26. package/dist/factor-DDOC7X6P.js +65 -0
  27. package/dist/fcl-CPC2WYrI.js +103 -0
  28. package/dist/forth-BmxRyE9S.js +60 -0
  29. package/dist/fortran-9bvPyrOW.js +442 -0
  30. package/dist/framework.js +288 -29
  31. package/dist/gas-BdfkXJT_.js +183 -0
  32. package/dist/gherkin-CJuwpceU.js +34 -0
  33. package/dist/groovy-DZeT_VM-.js +146 -0
  34. package/dist/haskell-Bvt3Qq1t.js +375 -0
  35. package/dist/haxe-70NVW1pR.js +359 -0
  36. package/dist/http-D9LttvKF.js +44 -0
  37. package/dist/idl-B6TRFYjl.js +947 -0
  38. package/dist/{assets/index-C7zlEJy8.js → index-B83didIY.js} +229 -302
  39. package/dist/{assets/index-BT8o9-M5.js → index-BKR3ecN5.js} +267 -386
  40. package/dist/{assets/index-B1srGfDb.js → index-BN-_cebP.js} +119 -165
  41. package/dist/index-BUHouW8T.js +249 -0
  42. package/dist/index-BW3krAiY.js +341 -0
  43. package/dist/index-C6tcHNVl.js +75 -0
  44. package/dist/index-CGyGGihY.js +538 -0
  45. package/dist/{assets/index-DMTL7O1s.js → index-CnQ56kqq.js} +570 -586
  46. package/dist/index-Cv6c_1IG.js +71 -0
  47. package/dist/{assets/index-CeeaNa4F.js → index-CxMfHOup.js} +136 -167
  48. package/dist/index-DRL7VovM.js +308 -0
  49. package/dist/index-Dfcy8w9c.js +58 -0
  50. package/dist/{assets/index-CtmpJVwa.js → index-DyGIijU2.js} +270 -312
  51. package/dist/index-Ek7_XgGk.js +98 -0
  52. package/dist/{assets/index-Bv_z_qRq.js → index-TSGli7LX.js} +121 -124
  53. package/dist/index-UnPPbmRc.js +145659 -0
  54. package/dist/{assets/index-BKF-A58l.js → index-xFQltarK.js} +79 -92
  55. package/dist/index.css +9 -18
  56. package/dist/javascript-WMWNx-Vj.js +690 -0
  57. package/dist/jinja2-DnB6dQmV.js +154 -0
  58. package/dist/julia-DpvXAuO6.js +241 -0
  59. package/dist/livescript-CanGTf8u.js +272 -0
  60. package/dist/lua-XplVlWi_.js +217 -0
  61. package/dist/mathematica-jaRHnSxC.js +35 -0
  62. package/dist/mbox-BctzC1hL.js +76 -0
  63. package/dist/mirc-CFBPAOaF.js +72 -0
  64. package/dist/mllike-BSnXJBGA.js +272 -0
  65. package/dist/modelica-vUgVs--1.js +93 -0
  66. package/dist/mscgen-Cpl0NYLN.js +104 -0
  67. package/dist/mumps-CQoS1kWX.js +25 -0
  68. package/dist/nginx-zDPm3Z74.js +89 -0
  69. package/dist/nsis-fePjrhq7.js +62 -0
  70. package/dist/ntriples-CsNjv2QF.js +79 -0
  71. package/dist/octave-C8PmmSRH.js +143 -0
  72. package/dist/oz-Ce8aN8oE.js +151 -0
  73. package/dist/pascal-De0D6mP7.js +77 -0
  74. package/dist/perl-B4bSCe1C.js +915 -0
  75. package/dist/pig-D24Z8EXi.js +54 -0
  76. package/dist/powershell-DkYVfTzP.js +249 -0
  77. package/dist/properties-Dn9wna3M.js +26 -0
  78. package/dist/protobuf-BPIjwpzm.js +49 -0
  79. package/dist/pug-BqUR2bBq.js +248 -0
  80. package/dist/puppet-nyd4dhjf.js +45 -0
  81. package/dist/python-B5QdSKoL.js +313 -0
  82. package/dist/q-DXjKs-tC.js +83 -0
  83. package/dist/r-LKEuhEGI.js +104 -0
  84. package/dist/rpm-IznJm2Xc.js +57 -0
  85. package/dist/ruby-CcYfvIk6.js +228 -0
  86. package/dist/sas-7E8yHoCW.js +105 -0
  87. package/dist/scheme-DjibxsNh.js +124 -0
  88. package/dist/shell-C0C2sNA_.js +182 -0
  89. package/dist/sieve-Bwz7vjP5.js +72 -0
  90. package/dist/simple-mode-B0dvCdAA.js +89 -0
  91. package/dist/smalltalk-Bhddl2pB.js +48 -0
  92. package/dist/solr-BNlsLglM.js +41 -0
  93. package/dist/sparql-FarWu_Gb.js +197 -0
  94. package/dist/spreadsheet-C-cy4P5N.js +49 -0
  95. package/dist/sql-mMre1Bo3.js +282 -0
  96. package/dist/stex-92raWT1r.js +129 -0
  97. package/dist/stylus-CAdqWld3.js +250 -0
  98. package/dist/swift-DSxqR9R6.js +230 -0
  99. package/dist/tcl-xfoLljhY.js +81 -0
  100. package/dist/textile-D1AWE-pc.js +295 -0
  101. package/dist/tiddlywiki-5wqsXtSk.js +155 -0
  102. package/dist/tiki-__Kn3CeS.js +181 -0
  103. package/dist/toml-BHiuTcfn.js +49 -0
  104. package/dist/troff-D2UO-fKf.js +35 -0
  105. package/dist/ttcn-Bsa4sfRm.js +123 -0
  106. package/dist/ttcn-cfg-Bac_acMi.js +88 -0
  107. package/dist/turtle-xwJUxoPV.js +80 -0
  108. package/dist/vb-c2kQGd6-.js +74 -0
  109. package/dist/vbscript-Dz1TtKsy.js +324 -0
  110. package/dist/velocity-DJd0pTTC.js +96 -0
  111. package/dist/verilog-C4VGD9n1.js +263 -0
  112. package/dist/vhdl-T9HkrbI2.js +106 -0
  113. package/dist/webidl-CjfDENEo.js +155 -0
  114. package/dist/xquery-BUQdORAS.js +422 -0
  115. package/dist/yacas-C0absKBh.js +73 -0
  116. package/dist/z80-C8rPtw-0.js +61 -0
  117. package/package.json +4 -4
  118. package/dist/assets/apl-NdZ6-T1z.js +0 -142
  119. package/dist/assets/asciiarmor-CmJEbAuq.js +0 -56
  120. package/dist/assets/asn1-Ctc8K72v.js +0 -192
  121. package/dist/assets/asterisk-D6r__RMF.js +0 -187
  122. package/dist/assets/brainfuck-COwWCBpq.js +0 -70
  123. package/dist/assets/clike-C-PtfL50.js +0 -1019
  124. package/dist/assets/clojure-C2XPrGCa.js +0 -274
  125. package/dist/assets/cmake-BGrEgXCL.js +0 -81
  126. package/dist/assets/cobol-DShPmpZe.js +0 -234
  127. package/dist/assets/coffeescript-BG8vTfSz.js +0 -329
  128. package/dist/assets/commonlisp-8oE2EpEe.js +0 -108
  129. package/dist/assets/core-api-BMLS9FrT.js +0 -8288
  130. package/dist/assets/core-composables-DYxpIWyY.js +0 -1799
  131. package/dist/assets/core-constants-DiKDBbnD.js +0 -83
  132. package/dist/assets/core-directives-QhJx9kWh.js +0 -41
  133. package/dist/assets/core-interceptors-CSjUvxQ0.js +0 -78
  134. package/dist/assets/core-plugins-wv2bDZ0l.js +0 -4919
  135. package/dist/assets/core-services-CAfJRsjs.js +0 -4
  136. package/dist/assets/core-utilities-BTktq_a-.js +0 -33
  137. package/dist/assets/crystal--rIRMl16.js +0 -419
  138. package/dist/assets/css/core-directives-FL4vIIkN.css +0 -73
  139. package/dist/assets/css/fonts-M1mtyV8L.css +0 -305
  140. package/dist/assets/css/icons-css-DbCVsovz.css +0 -41
  141. package/dist/assets/css/shared-components-bnLHdCtf.css +0 -429
  142. package/dist/assets/css/shared-modules-CNOICmYQ.css +0 -45
  143. package/dist/assets/css/styles-C62nDZwV.css +0 -4096
  144. package/dist/assets/css/ui-app-Bh9hmlIB.css +0 -1287
  145. package/dist/assets/css/ui-content-B29jsmK7.css +0 -1187
  146. package/dist/assets/css/ui-controls-CRtfFczw.css +0 -387
  147. package/dist/assets/css/ui-data-CYLxfdUa.css +0 -1555
  148. package/dist/assets/css/ui-form-C3WrWfVl.css +0 -71
  149. package/dist/assets/css/ui-form-fields-DOtHhDeM.css +0 -1360
  150. package/dist/assets/css/ui-helpers-bOoNv5dS.css +0 -37
  151. package/dist/assets/css/ui-indicators-CybQnCoU.css +0 -628
  152. package/dist/assets/css/ui-layout-DyGKgizy.css +0 -251
  153. package/dist/assets/css/ui-media-TWYep8js.css +0 -298
  154. package/dist/assets/css/ui-media-advanced-BGxy3VSB.css +0 -183
  155. package/dist/assets/css/ui-navigation-DcPRn8SB.css +0 -1693
  156. package/dist/assets/css-C_ZeEwz2.js +0 -847
  157. package/dist/assets/cypher-Bayei42D.js +0 -122
  158. package/dist/assets/d-B0hhz6be.js +0 -205
  159. package/dist/assets/diff-DQutOIXs.js +0 -30
  160. package/dist/assets/dtd-C1CeYVnM.js +0 -121
  161. package/dist/assets/dylan-Dm9-uD-A.js +0 -337
  162. package/dist/assets/ebnf-jWG_1Yly.js +0 -151
  163. package/dist/assets/ecl-CgJPA6z9.js +0 -190
  164. package/dist/assets/eiffel-lj7uLahq.js +0 -146
  165. package/dist/assets/elm-Cz7o1ijk.js +0 -230
  166. package/dist/assets/erlang-CyL5QOyR.js +0 -581
  167. package/dist/assets/factor-BVWHwYpu.js +0 -65
  168. package/dist/assets/fcl-DiozYjc8.js +0 -154
  169. package/dist/assets/forth-B7vn5ze0.js +0 -164
  170. package/dist/assets/fortran-D2XNEnBT.js +0 -172
  171. package/dist/assets/gas-B_Tj57Ve.js +0 -343
  172. package/dist/assets/gherkin-CJ6Qk4EZ.js +0 -147
  173. package/dist/assets/groovy-ioGz2WSV.js +0 -228
  174. package/dist/assets/haskell-BHnm1B83.js +0 -239
  175. package/dist/assets/haxe-Bn6Yo6N3.js +0 -490
  176. package/dist/assets/http-BOd5SYCT.js +0 -89
  177. package/dist/assets/idl-FSFk8_xX.js +0 -274
  178. package/dist/assets/index--5fKpGeN.js +0 -792
  179. package/dist/assets/index-0lME64YH.js +0 -342
  180. package/dist/assets/index-B6Ip0FgO.js +0 -437
  181. package/dist/assets/index-BmV05E5M.js +0 -479
  182. package/dist/assets/index-C6MavZDA.js +0 -131
  183. package/dist/assets/index-CwKpgcYl.js +0 -85
  184. package/dist/assets/index-DRUmDL0J.js +0 -59
  185. package/dist/assets/index-DgFC-M9G.js +0 -96
  186. package/dist/assets/javascript-DGrAs70C.js +0 -922
  187. package/dist/assets/jinja2-D9k5QrXv.js +0 -171
  188. package/dist/assets/julia-DM42tOPB.js +0 -369
  189. package/dist/assets/livescript-Dci8HnOi.js +0 -259
  190. package/dist/assets/lua-CByQu4v6.js +0 -137
  191. package/dist/assets/lucide-icons-af0BY3bi.js +0 -34555
  192. package/dist/assets/mathematica-Dkv0uCYF.js +0 -153
  193. package/dist/assets/mbox-CYTvs5kC.js +0 -114
  194. package/dist/assets/mirc-DpgP3GCo.js +0 -176
  195. package/dist/assets/mllike-C6tNn2Yt.js +0 -343
  196. package/dist/assets/modelica-CR6hTSce.js +0 -192
  197. package/dist/assets/mscgen-D0GXtzMS.js +0 -149
  198. package/dist/assets/mumps-Bf1EyDa6.js +0 -129
  199. package/dist/assets/nginx-By9Phklj.js +0 -163
  200. package/dist/assets/nsis-B5ggMLQ9.js +0 -80
  201. package/dist/assets/ntriples-C7VJ7pnm.js +0 -141
  202. package/dist/assets/octave-6yR_ix15.js +0 -112
  203. package/dist/assets/oz-CEUnktiQ.js +0 -235
  204. package/dist/assets/pascal-Dksf1EyF.js +0 -124
  205. package/dist/assets/perl-B99DUQQt.js +0 -819
  206. package/dist/assets/pig-DFeDRta6.js +0 -149
  207. package/dist/assets/powershell-DhwsNWMx.js +0 -381
  208. package/dist/assets/properties-o21uErwC.js +0 -62
  209. package/dist/assets/protobuf-YxlANsmD.js +0 -54
  210. package/dist/assets/pug-bUgjeODZ.js +0 -504
  211. package/dist/assets/puppet-B8WICGYE.js +0 -205
  212. package/dist/assets/python-D3FFx1Id.js +0 -389
  213. package/dist/assets/q-D2Hjhl2C.js +0 -123
  214. package/dist/assets/r-D73k5lac.js +0 -174
  215. package/dist/assets/rpm-Duv_WH0z.js +0 -89
  216. package/dist/assets/ruby-DGCVqZDt.js +0 -287
  217. package/dist/assets/sas-XjPv1Vy5.js +0 -268
  218. package/dist/assets/scheme-DeaA28vt.js +0 -263
  219. package/dist/assets/shared-components-CfAt2hC6.js +0 -1501
  220. package/dist/assets/shared-composables-v9NkNuAe.js +0 -35
  221. package/dist/assets/shared-modules-CDP-H5ZB.js +0 -3588
  222. package/dist/assets/shared-pages-BGRRA5WB.js +0 -20
  223. package/dist/assets/shell-Bx6QZTgx.js +0 -145
  224. package/dist/assets/sieve-CWCD62sW.js +0 -178
  225. package/dist/assets/simple-mode-BAO9cD7H.js +0 -136
  226. package/dist/assets/smalltalk-DSQbF4MF.js +0 -153
  227. package/dist/assets/solr-v_XRf31C.js +0 -80
  228. package/dist/assets/sparql-BrfDqf0-.js +0 -170
  229. package/dist/assets/spreadsheet-Csn84Pef.js +0 -98
  230. package/dist/assets/sql-D4utlq1l.js +0 -480
  231. package/dist/assets/stex-DBkktma-.js +0 -246
  232. package/dist/assets/stylus-ByG-Fd6f.js +0 -750
  233. package/dist/assets/swift-CHbTprt3.js +0 -202
  234. package/dist/assets/tcl-BRlMUELr.js +0 -125
  235. package/dist/assets/textile-CqfTUjd4.js +0 -441
  236. package/dist/assets/tiddlywiki-BrsoM8KB.js +0 -278
  237. package/dist/assets/tiki-D-ivWPkc.js +0 -289
  238. package/dist/assets/toml-t_IhJu83.js +0 -75
  239. package/dist/assets/troff-DckGF2AE.js +0 -64
  240. package/dist/assets/ttcn-B8TAFbRR.js +0 -253
  241. package/dist/assets/ttcn-cfg-NHh25oCM.js +0 -197
  242. package/dist/assets/turtle-D9Js0BlL.js +0 -141
  243. package/dist/assets/ui-app-D31Pr1WY.js +0 -1993
  244. package/dist/assets/ui-content-B7SxH8y9.js +0 -52887
  245. package/dist/assets/ui-controls-nmDJYLmC.js +0 -348
  246. package/dist/assets/ui-data-Ci3b1ye0.js +0 -22901
  247. package/dist/assets/ui-form-Cs5ooOo7.js +0 -159
  248. package/dist/assets/ui-form-fields-DFQi31jT.js +0 -40575
  249. package/dist/assets/ui-helpers-CF-EUlOg.js +0 -1736
  250. package/dist/assets/ui-indicators-mIQeEqha.js +0 -199
  251. package/dist/assets/ui-layout-v2XBQky3.js +0 -320
  252. package/dist/assets/ui-media-WWYrwmZw.js +0 -1259
  253. package/dist/assets/ui-media-advanced-T8ibi153.js +0 -492
  254. package/dist/assets/ui-modals-BdZXzI85.js +0 -2
  255. package/dist/assets/ui-navigation-BtHa6ovW.js +0 -24269
  256. package/dist/assets/utils-DZK5fu48.js +0 -17216
  257. package/dist/assets/vb-CbIGLrpY.js +0 -249
  258. package/dist/assets/vbscript-8ANWle9n.js +0 -320
  259. package/dist/assets/velocity-D6hz3Hzw.js +0 -186
  260. package/dist/assets/verilog-DIV442at.js +0 -565
  261. package/dist/assets/vhdl-BlTiZo_v.js +0 -174
  262. package/dist/assets/vueuse-CTQm4Zh0.js +0 -9308
  263. package/dist/assets/webidl-Cp3tcqdk.js +0 -179
  264. package/dist/assets/xquery-Dd4TBzXv.js +0 -411
  265. package/dist/assets/yacas-DQ1WucF0.js +0 -182
  266. package/dist/assets/z80-P1j44jDI.js +0 -102
@@ -1,922 +0,0 @@
1
- function mkJavaScript(parserConfig) {
2
- var statementIndent = parserConfig.statementIndent;
3
- var jsonldMode = parserConfig.jsonld;
4
- var jsonMode = parserConfig.json || jsonldMode;
5
- var isTS = parserConfig.typescript;
6
- var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
7
-
8
- // Tokenizer
9
-
10
- var keywords = function(){
11
- function kw(type) {return {type: type, style: "keyword"};}
12
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
13
- var operator = kw("operator"), atom = {type: "atom", style: "atom"};
14
-
15
- return {
16
- "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
17
- "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
18
- "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
19
- "function": kw("function"), "catch": kw("catch"),
20
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
21
- "in": operator, "typeof": operator, "instanceof": operator,
22
- "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
23
- "this": kw("this"), "class": kw("class"), "super": kw("atom"),
24
- "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
25
- "await": C
26
- };
27
- }();
28
-
29
- var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
30
- var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
31
-
32
- function readRegexp(stream) {
33
- var escaped = false, next, inSet = false;
34
- while ((next = stream.next()) != null) {
35
- if (!escaped) {
36
- if (next == "/" && !inSet) return;
37
- if (next == "[") inSet = true;
38
- else if (inSet && next == "]") inSet = false;
39
- }
40
- escaped = !escaped && next == "\\";
41
- }
42
- }
43
-
44
- // Used as scratch variables to communicate multiple values without
45
- // consing up tons of objects.
46
- var type, content;
47
- function ret(tp, style, cont) {
48
- type = tp; content = cont;
49
- return style;
50
- }
51
- function tokenBase(stream, state) {
52
- var ch = stream.next();
53
- if (ch == '"' || ch == "'") {
54
- state.tokenize = tokenString(ch);
55
- return state.tokenize(stream, state);
56
- } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
57
- return ret("number", "number");
58
- } else if (ch == "." && stream.match("..")) {
59
- return ret("spread", "meta");
60
- } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
61
- return ret(ch);
62
- } else if (ch == "=" && stream.eat(">")) {
63
- return ret("=>", "operator");
64
- } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
65
- return ret("number", "number");
66
- } else if (/\d/.test(ch)) {
67
- stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
68
- return ret("number", "number");
69
- } else if (ch == "/") {
70
- if (stream.eat("*")) {
71
- state.tokenize = tokenComment;
72
- return tokenComment(stream, state);
73
- } else if (stream.eat("/")) {
74
- stream.skipToEnd();
75
- return ret("comment", "comment");
76
- } else if (expressionAllowed(stream, state, 1)) {
77
- readRegexp(stream);
78
- stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
79
- return ret("regexp", "string.special");
80
- } else {
81
- stream.eat("=");
82
- return ret("operator", "operator", stream.current());
83
- }
84
- } else if (ch == "`") {
85
- state.tokenize = tokenQuasi;
86
- return tokenQuasi(stream, state);
87
- } else if (ch == "#" && stream.peek() == "!") {
88
- stream.skipToEnd();
89
- return ret("meta", "meta");
90
- } else if (ch == "#" && stream.eatWhile(wordRE)) {
91
- return ret("variable", "property")
92
- } else if (ch == "<" && stream.match("!--") ||
93
- (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
94
- stream.skipToEnd();
95
- return ret("comment", "comment")
96
- } else if (isOperatorChar.test(ch)) {
97
- if (ch != ">" || !state.lexical || state.lexical.type != ">") {
98
- if (stream.eat("=")) {
99
- if (ch == "!" || ch == "=") stream.eat("=");
100
- } else if (/[<>*+\-|&?]/.test(ch)) {
101
- stream.eat(ch);
102
- if (ch == ">") stream.eat(ch);
103
- }
104
- }
105
- if (ch == "?" && stream.eat(".")) return ret(".")
106
- return ret("operator", "operator", stream.current());
107
- } else if (wordRE.test(ch)) {
108
- stream.eatWhile(wordRE);
109
- var word = stream.current();
110
- if (state.lastType != ".") {
111
- if (keywords.propertyIsEnumerable(word)) {
112
- var kw = keywords[word];
113
- return ret(kw.type, kw.style, word)
114
- }
115
- if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
116
- return ret("async", "keyword", word)
117
- }
118
- return ret("variable", "variable", word)
119
- }
120
- }
121
-
122
- function tokenString(quote) {
123
- return function(stream, state) {
124
- var escaped = false, next;
125
- if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
126
- state.tokenize = tokenBase;
127
- return ret("jsonld-keyword", "meta");
128
- }
129
- while ((next = stream.next()) != null) {
130
- if (next == quote && !escaped) break;
131
- escaped = !escaped && next == "\\";
132
- }
133
- if (!escaped) state.tokenize = tokenBase;
134
- return ret("string", "string");
135
- };
136
- }
137
-
138
- function tokenComment(stream, state) {
139
- var maybeEnd = false, ch;
140
- while (ch = stream.next()) {
141
- if (ch == "/" && maybeEnd) {
142
- state.tokenize = tokenBase;
143
- break;
144
- }
145
- maybeEnd = (ch == "*");
146
- }
147
- return ret("comment", "comment");
148
- }
149
-
150
- function tokenQuasi(stream, state) {
151
- var escaped = false, next;
152
- while ((next = stream.next()) != null) {
153
- if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
154
- state.tokenize = tokenBase;
155
- break;
156
- }
157
- escaped = !escaped && next == "\\";
158
- }
159
- return ret("quasi", "string.special", stream.current());
160
- }
161
-
162
- var brackets = "([{}])";
163
- // This is a crude lookahead trick to try and notice that we're
164
- // parsing the argument patterns for a fat-arrow function before we
165
- // actually hit the arrow token. It only works if the arrow is on
166
- // the same line as the arguments and there's no strange noise
167
- // (comments) in between. Fallback is to only notice when we hit the
168
- // arrow, and not declare the arguments as locals for the arrow
169
- // body.
170
- function findFatArrow(stream, state) {
171
- if (state.fatArrowAt) state.fatArrowAt = null;
172
- var arrow = stream.string.indexOf("=>", stream.start);
173
- if (arrow < 0) return;
174
-
175
- if (isTS) { // Try to skip TypeScript return type declarations after the arguments
176
- var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow));
177
- if (m) arrow = m.index;
178
- }
179
-
180
- var depth = 0, sawSomething = false;
181
- for (var pos = arrow - 1; pos >= 0; --pos) {
182
- var ch = stream.string.charAt(pos);
183
- var bracket = brackets.indexOf(ch);
184
- if (bracket >= 0 && bracket < 3) {
185
- if (!depth) { ++pos; break; }
186
- if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
187
- } else if (bracket >= 3 && bracket < 6) {
188
- ++depth;
189
- } else if (wordRE.test(ch)) {
190
- sawSomething = true;
191
- } else if (/["'\/`]/.test(ch)) {
192
- for (;; --pos) {
193
- if (pos == 0) return
194
- var next = stream.string.charAt(pos - 1);
195
- if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
196
- }
197
- } else if (sawSomething && !depth) {
198
- ++pos;
199
- break;
200
- }
201
- }
202
- if (sawSomething && !depth) state.fatArrowAt = pos;
203
- }
204
-
205
- // Parser
206
-
207
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
208
- "regexp": true, "this": true, "import": true, "jsonld-keyword": true};
209
-
210
- function JSLexical(indented, column, type, align, prev, info) {
211
- this.indented = indented;
212
- this.column = column;
213
- this.type = type;
214
- this.prev = prev;
215
- this.info = info;
216
- if (align != null) this.align = align;
217
- }
218
-
219
- function inScope(state, varname) {
220
- for (var v = state.localVars; v; v = v.next)
221
- if (v.name == varname) return true;
222
- for (var cx = state.context; cx; cx = cx.prev) {
223
- for (var v = cx.vars; v; v = v.next)
224
- if (v.name == varname) return true;
225
- }
226
- }
227
-
228
- function parseJS(state, style, type, content, stream) {
229
- var cc = state.cc;
230
- // Communicate our context to the combinators.
231
- // (Less wasteful than consing up a hundred closures on every call.)
232
- cx.state = state; cx.stream = stream; cx.marked = null; cx.cc = cc; cx.style = style;
233
-
234
- if (!state.lexical.hasOwnProperty("align"))
235
- state.lexical.align = true;
236
-
237
- while(true) {
238
- var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
239
- if (combinator(type, content)) {
240
- while(cc.length && cc[cc.length - 1].lex)
241
- cc.pop()();
242
- if (cx.marked) return cx.marked;
243
- if (type == "variable" && inScope(state, content)) return "variableName.local";
244
- return style;
245
- }
246
- }
247
- }
248
-
249
- // Combinator utils
250
-
251
- var cx = {state: null, marked: null, cc: null};
252
- function pass() {
253
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
254
- }
255
- function cont() {
256
- pass.apply(null, arguments);
257
- return true;
258
- }
259
- function inList(name, list) {
260
- for (var v = list; v; v = v.next) if (v.name == name) return true
261
- return false;
262
- }
263
- function register(varname) {
264
- var state = cx.state;
265
- cx.marked = "def";
266
- if (state.context) {
267
- if (state.lexical.info == "var" && state.context && state.context.block) {
268
- // FIXME function decls are also not block scoped
269
- var newContext = registerVarScoped(varname, state.context);
270
- if (newContext != null) {
271
- state.context = newContext;
272
- return
273
- }
274
- } else if (!inList(varname, state.localVars)) {
275
- state.localVars = new Var(varname, state.localVars);
276
- return
277
- }
278
- }
279
- // Fall through means this is global
280
- if (parserConfig.globalVars && !inList(varname, state.globalVars))
281
- state.globalVars = new Var(varname, state.globalVars);
282
- }
283
- function registerVarScoped(varname, context) {
284
- if (!context) {
285
- return null
286
- } else if (context.block) {
287
- var inner = registerVarScoped(varname, context.prev);
288
- if (!inner) return null
289
- if (inner == context.prev) return context
290
- return new Context(inner, context.vars, true)
291
- } else if (inList(varname, context.vars)) {
292
- return context
293
- } else {
294
- return new Context(context.prev, new Var(varname, context.vars), false)
295
- }
296
- }
297
-
298
- function isModifier(name) {
299
- return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
300
- }
301
-
302
- // Combinators
303
-
304
- function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block; }
305
- function Var(name, next) { this.name = name; this.next = next; }
306
-
307
- var defaultVars = new Var("this", new Var("arguments", null));
308
- function pushcontext() {
309
- cx.state.context = new Context(cx.state.context, cx.state.localVars, false);
310
- cx.state.localVars = defaultVars;
311
- }
312
- function pushblockcontext() {
313
- cx.state.context = new Context(cx.state.context, cx.state.localVars, true);
314
- cx.state.localVars = null;
315
- }
316
- pushcontext.lex = pushblockcontext.lex = true;
317
- function popcontext() {
318
- cx.state.localVars = cx.state.context.vars;
319
- cx.state.context = cx.state.context.prev;
320
- }
321
- popcontext.lex = true;
322
- function pushlex(type, info) {
323
- var result = function() {
324
- var state = cx.state, indent = state.indented;
325
- if (state.lexical.type == "stat") indent = state.lexical.indented;
326
- else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
327
- indent = outer.indented;
328
- state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
329
- };
330
- result.lex = true;
331
- return result;
332
- }
333
- function poplex() {
334
- var state = cx.state;
335
- if (state.lexical.prev) {
336
- if (state.lexical.type == ")")
337
- state.indented = state.lexical.indented;
338
- state.lexical = state.lexical.prev;
339
- }
340
- }
341
- poplex.lex = true;
342
-
343
- function expect(wanted) {
344
- function exp(type) {
345
- if (type == wanted) return cont();
346
- else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
347
- else return cont(exp);
348
- } return exp;
349
- }
350
-
351
- function statement(type, value) {
352
- if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
353
- if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
354
- if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
355
- if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
356
- if (type == "debugger") return cont(expect(";"));
357
- if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
358
- if (type == ";") return cont();
359
- if (type == "if") {
360
- if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
361
- cx.state.cc.pop()();
362
- return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
363
- }
364
- if (type == "function") return cont(functiondef);
365
- if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
366
- if (type == "class" || (isTS && value == "interface")) {
367
- cx.marked = "keyword";
368
- return cont(pushlex("form", type == "class" ? type : value), className, poplex)
369
- }
370
- if (type == "variable") {
371
- if (isTS && value == "declare") {
372
- cx.marked = "keyword";
373
- return cont(statement)
374
- } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
375
- cx.marked = "keyword";
376
- if (value == "enum") return cont(enumdef);
377
- else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
378
- else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
379
- } else if (isTS && value == "namespace") {
380
- cx.marked = "keyword";
381
- return cont(pushlex("form"), expression, statement, poplex)
382
- } else if (isTS && value == "abstract") {
383
- cx.marked = "keyword";
384
- return cont(statement)
385
- } else {
386
- return cont(pushlex("stat"), maybelabel);
387
- }
388
- }
389
- if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
390
- block, poplex, poplex, popcontext);
391
- if (type == "case") return cont(expression, expect(":"));
392
- if (type == "default") return cont(expect(":"));
393
- if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
394
- if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
395
- if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
396
- if (type == "async") return cont(statement)
397
- if (value == "@") return cont(expression, statement)
398
- return pass(pushlex("stat"), expression, expect(";"), poplex);
399
- }
400
- function maybeCatchBinding(type) {
401
- if (type == "(") return cont(funarg, expect(")"))
402
- }
403
- function expression(type, value) {
404
- return expressionInner(type, value, false);
405
- }
406
- function expressionNoComma(type, value) {
407
- return expressionInner(type, value, true);
408
- }
409
- function parenExpr(type) {
410
- if (type != "(") return pass()
411
- return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
412
- }
413
- function expressionInner(type, value, noComma) {
414
- if (cx.state.fatArrowAt == cx.stream.start) {
415
- var body = noComma ? arrowBodyNoComma : arrowBody;
416
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
417
- else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
418
- }
419
-
420
- var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
421
- if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
422
- if (type == "function") return cont(functiondef, maybeop);
423
- if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
424
- if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
425
- if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
426
- if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
427
- if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
428
- if (type == "{") return contCommasep(objprop, "}", null, maybeop);
429
- if (type == "quasi") return pass(quasi, maybeop);
430
- if (type == "new") return cont(maybeTarget(noComma));
431
- return cont();
432
- }
433
- function maybeexpression(type) {
434
- if (type.match(/[;\}\)\],]/)) return pass();
435
- return pass(expression);
436
- }
437
-
438
- function maybeoperatorComma(type, value) {
439
- if (type == ",") return cont(maybeexpression);
440
- return maybeoperatorNoComma(type, value, false);
441
- }
442
- function maybeoperatorNoComma(type, value, noComma) {
443
- var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
444
- var expr = noComma == false ? expression : expressionNoComma;
445
- if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
446
- if (type == "operator") {
447
- if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
448
- if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
449
- return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
450
- if (value == "?") return cont(expression, expect(":"), expr);
451
- return cont(expr);
452
- }
453
- if (type == "quasi") { return pass(quasi, me); }
454
- if (type == ";") return;
455
- if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
456
- if (type == ".") return cont(property, me);
457
- if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
458
- if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
459
- if (type == "regexp") {
460
- cx.state.lastType = cx.marked = "operator";
461
- cx.stream.backUp(cx.stream.pos - cx.stream.start - 1);
462
- return cont(expr)
463
- }
464
- }
465
- function quasi(type, value) {
466
- if (type != "quasi") return pass();
467
- if (value.slice(value.length - 2) != "${") return cont(quasi);
468
- return cont(maybeexpression, continueQuasi);
469
- }
470
- function continueQuasi(type) {
471
- if (type == "}") {
472
- cx.marked = "string.special";
473
- cx.state.tokenize = tokenQuasi;
474
- return cont(quasi);
475
- }
476
- }
477
- function arrowBody(type) {
478
- findFatArrow(cx.stream, cx.state);
479
- return pass(type == "{" ? statement : expression);
480
- }
481
- function arrowBodyNoComma(type) {
482
- findFatArrow(cx.stream, cx.state);
483
- return pass(type == "{" ? statement : expressionNoComma);
484
- }
485
- function maybeTarget(noComma) {
486
- return function(type) {
487
- if (type == ".") return cont(noComma ? targetNoComma : target);
488
- else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
489
- else return pass(noComma ? expressionNoComma : expression);
490
- };
491
- }
492
- function target(_, value) {
493
- if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
494
- }
495
- function targetNoComma(_, value) {
496
- if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
497
- }
498
- function maybelabel(type) {
499
- if (type == ":") return cont(poplex, statement);
500
- return pass(maybeoperatorComma, expect(";"), poplex);
501
- }
502
- function property(type) {
503
- if (type == "variable") {cx.marked = "property"; return cont();}
504
- }
505
- function objprop(type, value) {
506
- if (type == "async") {
507
- cx.marked = "property";
508
- return cont(objprop);
509
- } else if (type == "variable" || cx.style == "keyword") {
510
- cx.marked = "property";
511
- if (value == "get" || value == "set") return cont(getterSetter);
512
- var m; // Work around fat-arrow-detection complication for detecting typescript typed arrow params
513
- if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
514
- cx.state.fatArrowAt = cx.stream.pos + m[0].length;
515
- return cont(afterprop);
516
- } else if (type == "number" || type == "string") {
517
- cx.marked = jsonldMode ? "property" : (cx.style + " property");
518
- return cont(afterprop);
519
- } else if (type == "jsonld-keyword") {
520
- return cont(afterprop);
521
- } else if (isTS && isModifier(value)) {
522
- cx.marked = "keyword";
523
- return cont(objprop)
524
- } else if (type == "[") {
525
- return cont(expression, maybetype, expect("]"), afterprop);
526
- } else if (type == "spread") {
527
- return cont(expressionNoComma, afterprop);
528
- } else if (value == "*") {
529
- cx.marked = "keyword";
530
- return cont(objprop);
531
- } else if (type == ":") {
532
- return pass(afterprop)
533
- }
534
- }
535
- function getterSetter(type) {
536
- if (type != "variable") return pass(afterprop);
537
- cx.marked = "property";
538
- return cont(functiondef);
539
- }
540
- function afterprop(type) {
541
- if (type == ":") return cont(expressionNoComma);
542
- if (type == "(") return pass(functiondef);
543
- }
544
- function commasep(what, end, sep) {
545
- function proceed(type, value) {
546
- if (sep ? sep.indexOf(type) > -1 : type == ",") {
547
- var lex = cx.state.lexical;
548
- if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
549
- return cont(function(type, value) {
550
- if (type == end || value == end) return pass()
551
- return pass(what)
552
- }, proceed);
553
- }
554
- if (type == end || value == end) return cont();
555
- if (sep && sep.indexOf(";") > -1) return pass(what)
556
- return cont(expect(end));
557
- }
558
- return function(type, value) {
559
- if (type == end || value == end) return cont();
560
- return pass(what, proceed);
561
- };
562
- }
563
- function contCommasep(what, end, info) {
564
- for (var i = 3; i < arguments.length; i++)
565
- cx.cc.push(arguments[i]);
566
- return cont(pushlex(end, info), commasep(what, end), poplex);
567
- }
568
- function block(type) {
569
- if (type == "}") return cont();
570
- return pass(statement, block);
571
- }
572
- function maybetype(type, value) {
573
- if (isTS) {
574
- if (type == ":") return cont(typeexpr);
575
- if (value == "?") return cont(maybetype);
576
- }
577
- }
578
- function maybetypeOrIn(type, value) {
579
- if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
580
- }
581
- function mayberettype(type) {
582
- if (isTS && type == ":") {
583
- if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
584
- else return cont(typeexpr)
585
- }
586
- }
587
- function isKW(_, value) {
588
- if (value == "is") {
589
- cx.marked = "keyword";
590
- return cont()
591
- }
592
- }
593
- function typeexpr(type, value) {
594
- if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
595
- cx.marked = "keyword";
596
- return cont(value == "typeof" ? expressionNoComma : typeexpr)
597
- }
598
- if (type == "variable" || value == "void") {
599
- cx.marked = "type";
600
- return cont(afterType)
601
- }
602
- if (value == "|" || value == "&") return cont(typeexpr)
603
- if (type == "string" || type == "number" || type == "atom") return cont(afterType);
604
- if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
605
- if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
606
- if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
607
- if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
608
- if (type == "quasi") return pass(quasiType, afterType)
609
- }
610
- function maybeReturnType(type) {
611
- if (type == "=>") return cont(typeexpr)
612
- }
613
- function typeprops(type) {
614
- if (type.match(/[\}\)\]]/)) return cont()
615
- if (type == "," || type == ";") return cont(typeprops)
616
- return pass(typeprop, typeprops)
617
- }
618
- function typeprop(type, value) {
619
- if (type == "variable" || cx.style == "keyword") {
620
- cx.marked = "property";
621
- return cont(typeprop)
622
- } else if (value == "?" || type == "number" || type == "string") {
623
- return cont(typeprop)
624
- } else if (type == ":") {
625
- return cont(typeexpr)
626
- } else if (type == "[") {
627
- return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
628
- } else if (type == "(") {
629
- return pass(functiondecl, typeprop)
630
- } else if (!type.match(/[;\}\)\],]/)) {
631
- return cont()
632
- }
633
- }
634
- function quasiType(type, value) {
635
- if (type != "quasi") return pass();
636
- if (value.slice(value.length - 2) != "${") return cont(quasiType);
637
- return cont(typeexpr, continueQuasiType);
638
- }
639
- function continueQuasiType(type) {
640
- if (type == "}") {
641
- cx.marked = "string.special";
642
- cx.state.tokenize = tokenQuasi;
643
- return cont(quasiType);
644
- }
645
- }
646
- function typearg(type, value) {
647
- if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
648
- if (type == ":") return cont(typeexpr)
649
- if (type == "spread") return cont(typearg)
650
- return pass(typeexpr)
651
- }
652
- function afterType(type, value) {
653
- if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
654
- if (value == "|" || type == "." || value == "&") return cont(typeexpr)
655
- if (type == "[") return cont(typeexpr, expect("]"), afterType)
656
- if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
657
- if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
658
- }
659
- function maybeTypeArgs(_, value) {
660
- if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
661
- }
662
- function typeparam() {
663
- return pass(typeexpr, maybeTypeDefault)
664
- }
665
- function maybeTypeDefault(_, value) {
666
- if (value == "=") return cont(typeexpr)
667
- }
668
- function vardef(_, value) {
669
- if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
670
- return pass(pattern, maybetype, maybeAssign, vardefCont);
671
- }
672
- function pattern(type, value) {
673
- if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
674
- if (type == "variable") { register(value); return cont(); }
675
- if (type == "spread") return cont(pattern);
676
- if (type == "[") return contCommasep(eltpattern, "]");
677
- if (type == "{") return contCommasep(proppattern, "}");
678
- }
679
- function proppattern(type, value) {
680
- if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
681
- register(value);
682
- return cont(maybeAssign);
683
- }
684
- if (type == "variable") cx.marked = "property";
685
- if (type == "spread") return cont(pattern);
686
- if (type == "}") return pass();
687
- if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
688
- return cont(expect(":"), pattern, maybeAssign);
689
- }
690
- function eltpattern() {
691
- return pass(pattern, maybeAssign)
692
- }
693
- function maybeAssign(_type, value) {
694
- if (value == "=") return cont(expressionNoComma);
695
- }
696
- function vardefCont(type) {
697
- if (type == ",") return cont(vardef);
698
- }
699
- function maybeelse(type, value) {
700
- if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
701
- }
702
- function forspec(type, value) {
703
- if (value == "await") return cont(forspec);
704
- if (type == "(") return cont(pushlex(")"), forspec1, poplex);
705
- }
706
- function forspec1(type) {
707
- if (type == "var") return cont(vardef, forspec2);
708
- if (type == "variable") return cont(forspec2);
709
- return pass(forspec2)
710
- }
711
- function forspec2(type, value) {
712
- if (type == ")") return cont()
713
- if (type == ";") return cont(forspec2)
714
- if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
715
- return pass(expression, forspec2)
716
- }
717
- function functiondef(type, value) {
718
- if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
719
- if (type == "variable") {register(value); return cont(functiondef);}
720
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
721
- if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
722
- }
723
- function functiondecl(type, value) {
724
- if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
725
- if (type == "variable") {register(value); return cont(functiondecl);}
726
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
727
- if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
728
- }
729
- function typename(type, value) {
730
- if (type == "keyword" || type == "variable") {
731
- cx.marked = "type";
732
- return cont(typename)
733
- } else if (value == "<") {
734
- return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
735
- }
736
- }
737
- function funarg(type, value) {
738
- if (value == "@") cont(expression, funarg);
739
- if (type == "spread") return cont(funarg);
740
- if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
741
- if (isTS && type == "this") return cont(maybetype, maybeAssign)
742
- return pass(pattern, maybetype, maybeAssign);
743
- }
744
- function classExpression(type, value) {
745
- // Class expressions may have an optional name.
746
- if (type == "variable") return className(type, value);
747
- return classNameAfter(type, value);
748
- }
749
- function className(type, value) {
750
- if (type == "variable") {register(value); return cont(classNameAfter);}
751
- }
752
- function classNameAfter(type, value) {
753
- if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
754
- if (value == "extends" || value == "implements" || (isTS && type == ",")) {
755
- if (value == "implements") cx.marked = "keyword";
756
- return cont(isTS ? typeexpr : expression, classNameAfter);
757
- }
758
- if (type == "{") return cont(pushlex("}"), classBody, poplex);
759
- }
760
- function classBody(type, value) {
761
- if (type == "async" ||
762
- (type == "variable" &&
763
- (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
764
- cx.stream.match(/^\s+#?[\w$\xa1-\uffff]/, false))) {
765
- cx.marked = "keyword";
766
- return cont(classBody);
767
- }
768
- if (type == "variable" || cx.style == "keyword") {
769
- cx.marked = "property";
770
- return cont(classfield, classBody);
771
- }
772
- if (type == "number" || type == "string") return cont(classfield, classBody);
773
- if (type == "[")
774
- return cont(expression, maybetype, expect("]"), classfield, classBody)
775
- if (value == "*") {
776
- cx.marked = "keyword";
777
- return cont(classBody);
778
- }
779
- if (isTS && type == "(") return pass(functiondecl, classBody)
780
- if (type == ";" || type == ",") return cont(classBody);
781
- if (type == "}") return cont();
782
- if (value == "@") return cont(expression, classBody)
783
- }
784
- function classfield(type, value) {
785
- if (value == "!" || value == "?") return cont(classfield)
786
- if (type == ":") return cont(typeexpr, maybeAssign)
787
- if (value == "=") return cont(expressionNoComma)
788
- var context = cx.state.lexical.prev, isInterface = context && context.info == "interface";
789
- return pass(isInterface ? functiondecl : functiondef)
790
- }
791
- function afterExport(type, value) {
792
- if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
793
- if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
794
- if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
795
- return pass(statement);
796
- }
797
- function exportField(type, value) {
798
- if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
799
- if (type == "variable") return pass(expressionNoComma, exportField);
800
- }
801
- function afterImport(type) {
802
- if (type == "string") return cont();
803
- if (type == "(") return pass(expression);
804
- if (type == ".") return pass(maybeoperatorComma);
805
- return pass(importSpec, maybeMoreImports, maybeFrom);
806
- }
807
- function importSpec(type, value) {
808
- if (type == "{") return contCommasep(importSpec, "}");
809
- if (type == "variable") register(value);
810
- if (value == "*") cx.marked = "keyword";
811
- return cont(maybeAs);
812
- }
813
- function maybeMoreImports(type) {
814
- if (type == ",") return cont(importSpec, maybeMoreImports)
815
- }
816
- function maybeAs(_type, value) {
817
- if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
818
- }
819
- function maybeFrom(_type, value) {
820
- if (value == "from") { cx.marked = "keyword"; return cont(expression); }
821
- }
822
- function arrayLiteral(type) {
823
- if (type == "]") return cont();
824
- return pass(commasep(expressionNoComma, "]"));
825
- }
826
- function enumdef() {
827
- return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
828
- }
829
- function enummember() {
830
- return pass(pattern, maybeAssign);
831
- }
832
-
833
- function isContinuedStatement(state, textAfter) {
834
- return state.lastType == "operator" || state.lastType == "," ||
835
- isOperatorChar.test(textAfter.charAt(0)) ||
836
- /[,.]/.test(textAfter.charAt(0));
837
- }
838
-
839
- function expressionAllowed(stream, state, backUp) {
840
- return state.tokenize == tokenBase &&
841
- /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
842
- (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp))))
843
- }
844
-
845
- // Interface
846
-
847
- return {
848
- name: parserConfig.name,
849
-
850
- startState: function(indentUnit) {
851
- var state = {
852
- tokenize: tokenBase,
853
- lastType: "sof",
854
- cc: [],
855
- lexical: new JSLexical(-indentUnit, 0, "block", false),
856
- localVars: parserConfig.localVars,
857
- context: parserConfig.localVars && new Context(null, null, false),
858
- indented: 0
859
- };
860
- if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
861
- state.globalVars = parserConfig.globalVars;
862
- return state;
863
- },
864
-
865
- token: function(stream, state) {
866
- if (stream.sol()) {
867
- if (!state.lexical.hasOwnProperty("align"))
868
- state.lexical.align = false;
869
- state.indented = stream.indentation();
870
- findFatArrow(stream, state);
871
- }
872
- if (state.tokenize != tokenComment && stream.eatSpace()) return null;
873
- var style = state.tokenize(stream, state);
874
- if (type == "comment") return style;
875
- state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
876
- return parseJS(state, style, type, content, stream);
877
- },
878
-
879
- indent: function(state, textAfter, cx) {
880
- if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return null;
881
- if (state.tokenize != tokenBase) return 0;
882
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
883
- // Kludge to prevent 'maybelse' from blocking lexical scope pops
884
- if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
885
- var c = state.cc[i];
886
- if (c == poplex) lexical = lexical.prev;
887
- else if (c != maybeelse && c != popcontext) break;
888
- }
889
- while ((lexical.type == "stat" || lexical.type == "form") &&
890
- (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
891
- (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
892
- !/^[,\.=+\-*:?[\(]/.test(textAfter))))
893
- lexical = lexical.prev;
894
- if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
895
- lexical = lexical.prev;
896
- var type = lexical.type, closing = firstChar == type;
897
-
898
- if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
899
- else if (type == "form" && firstChar == "{") return lexical.indented;
900
- else if (type == "form") return lexical.indented + cx.unit;
901
- else if (type == "stat")
902
- return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || cx.unit : 0);
903
- else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
904
- return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? cx.unit : 2 * cx.unit);
905
- else if (lexical.align) return lexical.column + (closing ? 0 : 1);
906
- else return lexical.indented + (closing ? 0 : cx.unit);
907
- },
908
-
909
- languageData: {
910
- indentOnInput: /^\s*(?:case .*?:|default:|\{|\})$/,
911
- commentTokens: jsonMode ? undefined : {line: "//", block: {open: "/*", close: "*/"}},
912
- closeBrackets: {brackets: ["(", "[", "{", "'", '"', "`"]},
913
- wordChars: "$"
914
- }
915
- };
916
- }
917
- const javascript = mkJavaScript({name: "javascript"});
918
- const json = mkJavaScript({name: "json", json: true});
919
- const jsonld = mkJavaScript({name: "json", jsonld: true});
920
- const typescript = mkJavaScript({name: "typescript", typescript: true});
921
-
922
- export { javascript, json, jsonld, typescript };