@milkdown/crepe 7.5.0 → 7.5.2

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 (584) hide show
  1. package/lib/cjs/index-N1cRxqdw.js +39 -0
  2. package/lib/cjs/index-N1cRxqdw.js.map +1 -0
  3. package/lib/cjs/{index-cpC-j5Nt.js → index-TGmNEvsj.js} +31 -40
  4. package/lib/cjs/index-TGmNEvsj.js.map +1 -0
  5. package/lib/cjs/index-dEVmN_aj.js +26 -0
  6. package/lib/cjs/index-dEVmN_aj.js.map +1 -0
  7. package/lib/cjs/index-fhKBUFkq.js +46 -0
  8. package/lib/cjs/index-fhKBUFkq.js.map +1 -0
  9. package/lib/cjs/index-ocxd4A-M.js +675 -0
  10. package/lib/cjs/index-ocxd4A-M.js.map +1 -0
  11. package/lib/cjs/{index-J3XY9IPt.js → index-rFFAL9YA.js} +9 -17
  12. package/lib/cjs/{index-J3XY9IPt.js.map → index-rFFAL9YA.js.map} +1 -1
  13. package/lib/cjs/index-rLAgJeYn.js +28 -0
  14. package/lib/cjs/index-rLAgJeYn.js.map +1 -0
  15. package/lib/cjs/index-tlx25I_m.js +36 -0
  16. package/lib/cjs/index-tlx25I_m.js.map +1 -0
  17. package/lib/cjs/index-uleaJDBC.js +19 -0
  18. package/lib/cjs/index-uleaJDBC.js.map +1 -0
  19. package/lib/cjs/index.js +150 -14
  20. package/lib/cjs/index.js.map +1 -1
  21. package/lib/cjs/{todoList-Ze4FLMlx.js → todoList-YYRQo7wG.js} +1 -12
  22. package/lib/cjs/todoList-YYRQo7wG.js.map +1 -0
  23. package/lib/esm/index-6JoGWH2I.js +17 -0
  24. package/lib/esm/index-6JoGWH2I.js.map +1 -0
  25. package/lib/esm/{index-MB6wQe1U.js → index-CMGDOz11.js} +5 -13
  26. package/lib/esm/{index-MB6wQe1U.js.map → index-CMGDOz11.js.map} +1 -1
  27. package/lib/esm/index-HlPKwzLC.js +34 -0
  28. package/lib/esm/index-HlPKwzLC.js.map +1 -0
  29. package/lib/esm/index-_A9vu1ED.js +673 -0
  30. package/lib/esm/index-_A9vu1ED.js.map +1 -0
  31. package/lib/esm/index-amuALmzU.js +26 -0
  32. package/lib/esm/index-amuALmzU.js.map +1 -0
  33. package/lib/esm/index-fVrfHXda.js +24 -0
  34. package/lib/esm/index-fVrfHXda.js.map +1 -0
  35. package/lib/esm/index-jU_6odT9.js +44 -0
  36. package/lib/esm/index-jU_6odT9.js.map +1 -0
  37. package/lib/esm/index-ohmbt6Ys.js +37 -0
  38. package/lib/esm/index-ohmbt6Ys.js.map +1 -0
  39. package/lib/esm/{index-A83StUe6.js → index-w69wbtEZ.js} +9 -18
  40. package/lib/esm/{index-A83StUe6.js.map → index-w69wbtEZ.js.map} +1 -1
  41. package/lib/esm/index.js +152 -12
  42. package/lib/esm/index.js.map +1 -1
  43. package/lib/esm/{todoList-M-PGJKde.js → todoList-9QsDDcmB.js} +2 -12
  44. package/lib/esm/todoList-9QsDDcmB.js.map +1 -0
  45. package/package.json +2 -4
  46. package/lib/cjs/_view-N32ied53.js +0 -27
  47. package/lib/cjs/_view-N32ied53.js.map +0 -1
  48. package/lib/cjs/apl-99bWvYTf.js +0 -145
  49. package/lib/cjs/apl-99bWvYTf.js.map +0 -1
  50. package/lib/cjs/asciiarmor-cf0JLIr_.js +0 -59
  51. package/lib/cjs/asciiarmor-cf0JLIr_.js.map +0 -1
  52. package/lib/cjs/asn1-H4XzAvBS.js +0 -195
  53. package/lib/cjs/asn1-H4XzAvBS.js.map +0 -1
  54. package/lib/cjs/asterisk-0FgJEfZB.js +0 -190
  55. package/lib/cjs/asterisk-0FgJEfZB.js.map +0 -1
  56. package/lib/cjs/brainfuck-JX7vRZy7.js +0 -73
  57. package/lib/cjs/brainfuck-JX7vRZy7.js.map +0 -1
  58. package/lib/cjs/clike-ueXlMQy5.js +0 -1034
  59. package/lib/cjs/clike-ueXlMQy5.js.map +0 -1
  60. package/lib/cjs/clojure-6iDAG5oi.js +0 -277
  61. package/lib/cjs/clojure-6iDAG5oi.js.map +0 -1
  62. package/lib/cjs/clsx-dASsG01A.js +0 -6
  63. package/lib/cjs/clsx-dASsG01A.js.map +0 -1
  64. package/lib/cjs/cmake-L0RIBnfc.js +0 -84
  65. package/lib/cjs/cmake-L0RIBnfc.js.map +0 -1
  66. package/lib/cjs/cobol-oxkMh1GJ.js +0 -238
  67. package/lib/cjs/cobol-oxkMh1GJ.js.map +0 -1
  68. package/lib/cjs/coffeescript--eauIeRQ.js +0 -332
  69. package/lib/cjs/coffeescript--eauIeRQ.js.map +0 -1
  70. package/lib/cjs/commonlisp-pgSu-q6f.js +0 -111
  71. package/lib/cjs/commonlisp-pgSu-q6f.js.map +0 -1
  72. package/lib/cjs/crystal-2y3I5ibZ.js +0 -422
  73. package/lib/cjs/crystal-2y3I5ibZ.js.map +0 -1
  74. package/lib/cjs/css-WH69cXzo.js +0 -855
  75. package/lib/cjs/css-WH69cXzo.js.map +0 -1
  76. package/lib/cjs/cypher-da-dqVyQ.js +0 -125
  77. package/lib/cjs/cypher-da-dqVyQ.js.map +0 -1
  78. package/lib/cjs/d-58J7EOkP.js +0 -208
  79. package/lib/cjs/d-58J7EOkP.js.map +0 -1
  80. package/lib/cjs/diff-437Hfzqm.js +0 -33
  81. package/lib/cjs/diff-437Hfzqm.js.map +0 -1
  82. package/lib/cjs/dockerfile-7i0OoaQe.js +0 -202
  83. package/lib/cjs/dockerfile-7i0OoaQe.js.map +0 -1
  84. package/lib/cjs/dtd-AKekCPPB.js +0 -124
  85. package/lib/cjs/dtd-AKekCPPB.js.map +0 -1
  86. package/lib/cjs/dylan-DLEmvz1I.js +0 -340
  87. package/lib/cjs/dylan-DLEmvz1I.js.map +0 -1
  88. package/lib/cjs/ebnf-36cJWqxB.js +0 -154
  89. package/lib/cjs/ebnf-36cJWqxB.js.map +0 -1
  90. package/lib/cjs/ecl-UWr5vJKJ.js +0 -193
  91. package/lib/cjs/ecl-UWr5vJKJ.js.map +0 -1
  92. package/lib/cjs/eiffel-Su-C9LAY.js +0 -149
  93. package/lib/cjs/eiffel-Su-C9LAY.js.map +0 -1
  94. package/lib/cjs/elm-vNNfVJj7.js +0 -233
  95. package/lib/cjs/elm-vNNfVJj7.js.map +0 -1
  96. package/lib/cjs/erlang-NM9dgYaS.js +0 -584
  97. package/lib/cjs/erlang-NM9dgYaS.js.map +0 -1
  98. package/lib/cjs/factor-RWs-4aWg.js +0 -68
  99. package/lib/cjs/factor-RWs-4aWg.js.map +0 -1
  100. package/lib/cjs/fcl-acUhGCfs.js +0 -157
  101. package/lib/cjs/fcl-acUhGCfs.js.map +0 -1
  102. package/lib/cjs/floating-ui.dom-2cjBpir5.js +0 -1134
  103. package/lib/cjs/floating-ui.dom-2cjBpir5.js.map +0 -1
  104. package/lib/cjs/forth-sDkE6z3A.js +0 -167
  105. package/lib/cjs/forth-sDkE6z3A.js.map +0 -1
  106. package/lib/cjs/fortran-gkb4yvdk.js +0 -175
  107. package/lib/cjs/fortran-gkb4yvdk.js.map +0 -1
  108. package/lib/cjs/gas-mNA0qvkv.js +0 -347
  109. package/lib/cjs/gas-mNA0qvkv.js.map +0 -1
  110. package/lib/cjs/gherkin-5uyKpXXh.js +0 -150
  111. package/lib/cjs/gherkin-5uyKpXXh.js.map +0 -1
  112. package/lib/cjs/go-5XitXoIZ.js +0 -167
  113. package/lib/cjs/go-5XitXoIZ.js.map +0 -1
  114. package/lib/cjs/groovy-mz3pWMKN.js +0 -233
  115. package/lib/cjs/groovy-mz3pWMKN.js.map +0 -1
  116. package/lib/cjs/haskell-9KaSS7kb.js +0 -242
  117. package/lib/cjs/haskell-9KaSS7kb.js.map +0 -1
  118. package/lib/cjs/haxe-L8h6Pvni.js +0 -494
  119. package/lib/cjs/haxe-L8h6Pvni.js.map +0 -1
  120. package/lib/cjs/helper-1aludV1Z.js +0 -15
  121. package/lib/cjs/helper-1aludV1Z.js.map +0 -1
  122. package/lib/cjs/http-BFQQnRR-.js +0 -92
  123. package/lib/cjs/http-BFQQnRR-.js.map +0 -1
  124. package/lib/cjs/idl-29T-AzAy.js +0 -277
  125. package/lib/cjs/idl-29T-AzAy.js.map +0 -1
  126. package/lib/cjs/index--sa4NMpW.js +0 -119
  127. package/lib/cjs/index--sa4NMpW.js.map +0 -1
  128. package/lib/cjs/index--tnUmqZ_.js +0 -108
  129. package/lib/cjs/index--tnUmqZ_.js.map +0 -1
  130. package/lib/cjs/index-1vHyMXH8.js +0 -203
  131. package/lib/cjs/index-1vHyMXH8.js.map +0 -1
  132. package/lib/cjs/index-28q261C7.js +0 -448
  133. package/lib/cjs/index-28q261C7.js.map +0 -1
  134. package/lib/cjs/index-55VIM-52.js +0 -156
  135. package/lib/cjs/index-55VIM-52.js.map +0 -1
  136. package/lib/cjs/index-92bwto5V.js +0 -405
  137. package/lib/cjs/index-92bwto5V.js.map +0 -1
  138. package/lib/cjs/index-Buu2tD9O.js +0 -534
  139. package/lib/cjs/index-Buu2tD9O.js.map +0 -1
  140. package/lib/cjs/index-E4Ist86Z.js +0 -532
  141. package/lib/cjs/index-E4Ist86Z.js.map +0 -1
  142. package/lib/cjs/index-FbNqlZU8.js +0 -263
  143. package/lib/cjs/index-FbNqlZU8.js.map +0 -1
  144. package/lib/cjs/index-HH5lPgpj.js +0 -443
  145. package/lib/cjs/index-HH5lPgpj.js.map +0 -1
  146. package/lib/cjs/index-J1-yHn7v.js +0 -128
  147. package/lib/cjs/index-J1-yHn7v.js.map +0 -1
  148. package/lib/cjs/index-Jztk6JlP.js +0 -25698
  149. package/lib/cjs/index-Jztk6JlP.js.map +0 -1
  150. package/lib/cjs/index-N6pPZY61.js +0 -191
  151. package/lib/cjs/index-N6pPZY61.js.map +0 -1
  152. package/lib/cjs/index-TUJs6KKL.js +0 -472
  153. package/lib/cjs/index-TUJs6KKL.js.map +0 -1
  154. package/lib/cjs/index-Tjg8KyK7.js +0 -398
  155. package/lib/cjs/index-Tjg8KyK7.js.map +0 -1
  156. package/lib/cjs/index-VYwHTL3F.js +0 -161
  157. package/lib/cjs/index-VYwHTL3F.js.map +0 -1
  158. package/lib/cjs/index-_GOdKqUK.js +0 -1147
  159. package/lib/cjs/index-_GOdKqUK.js.map +0 -1
  160. package/lib/cjs/index-cKQcw-eu.js +0 -386
  161. package/lib/cjs/index-cKQcw-eu.js.map +0 -1
  162. package/lib/cjs/index-c_OzudR7.js +0 -699
  163. package/lib/cjs/index-c_OzudR7.js.map +0 -1
  164. package/lib/cjs/index-cb-5m0vG.js +0 -2519
  165. package/lib/cjs/index-cb-5m0vG.js.map +0 -1
  166. package/lib/cjs/index-cpC-j5Nt.js.map +0 -1
  167. package/lib/cjs/index-crv_k6dv.js +0 -1353
  168. package/lib/cjs/index-crv_k6dv.js.map +0 -1
  169. package/lib/cjs/index-jlfsu92T.js +0 -362
  170. package/lib/cjs/index-jlfsu92T.js.map +0 -1
  171. package/lib/cjs/index-jn036wuh.js +0 -1045
  172. package/lib/cjs/index-jn036wuh.js.map +0 -1
  173. package/lib/cjs/index-kqz-P6o6.js +0 -55
  174. package/lib/cjs/index-kqz-P6o6.js.map +0 -1
  175. package/lib/cjs/index-lBumFRUQ.js +0 -209
  176. package/lib/cjs/index-lBumFRUQ.js.map +0 -1
  177. package/lib/cjs/index-lUNj3xuC.js +0 -81
  178. package/lib/cjs/index-lUNj3xuC.js.map +0 -1
  179. package/lib/cjs/index-mcxgNBq9.js +0 -464
  180. package/lib/cjs/index-mcxgNBq9.js.map +0 -1
  181. package/lib/cjs/index-nTfDKYYi.js +0 -1029
  182. package/lib/cjs/index-nTfDKYYi.js.map +0 -1
  183. package/lib/cjs/index-tBw4NmwY.js +0 -33852
  184. package/lib/cjs/index-tBw4NmwY.js.map +0 -1
  185. package/lib/cjs/index-vfzLCXfi.js +0 -774
  186. package/lib/cjs/index-vfzLCXfi.js.map +0 -1
  187. package/lib/cjs/index-von4W2LG.js +0 -356
  188. package/lib/cjs/index-von4W2LG.js.map +0 -1
  189. package/lib/cjs/index-zXSAHvAj.js +0 -1877
  190. package/lib/cjs/index-zXSAHvAj.js.map +0 -1
  191. package/lib/cjs/javascript-5-BTydbD.js +0 -928
  192. package/lib/cjs/javascript-5-BTydbD.js.map +0 -1
  193. package/lib/cjs/jinja2-BWMz4gPk.js +0 -174
  194. package/lib/cjs/jinja2-BWMz4gPk.js.map +0 -1
  195. package/lib/cjs/julia-dtR9J3KZ.js +0 -372
  196. package/lib/cjs/julia-dtR9J3KZ.js.map +0 -1
  197. package/lib/cjs/livescript-YxT0INe3.js +0 -262
  198. package/lib/cjs/livescript-YxT0INe3.js.map +0 -1
  199. package/lib/cjs/lua-h7_AXjy9.js +0 -140
  200. package/lib/cjs/lua-h7_AXjy9.js.map +0 -1
  201. package/lib/cjs/mathematica-Zc57fOr3.js +0 -156
  202. package/lib/cjs/mathematica-Zc57fOr3.js.map +0 -1
  203. package/lib/cjs/mbox-ltKsKgJd.js +0 -117
  204. package/lib/cjs/mbox-ltKsKgJd.js.map +0 -1
  205. package/lib/cjs/mirc-xTLeWqmy.js +0 -179
  206. package/lib/cjs/mirc-xTLeWqmy.js.map +0 -1
  207. package/lib/cjs/mllike-xukl-Kjp.js +0 -351
  208. package/lib/cjs/mllike-xukl-Kjp.js.map +0 -1
  209. package/lib/cjs/modelica-LsXtAawk.js +0 -195
  210. package/lib/cjs/modelica-LsXtAawk.js.map +0 -1
  211. package/lib/cjs/mscgen-9HooYIVW.js +0 -154
  212. package/lib/cjs/mscgen-9HooYIVW.js.map +0 -1
  213. package/lib/cjs/mumps-VXqGp84f.js +0 -132
  214. package/lib/cjs/mumps-VXqGp84f.js.map +0 -1
  215. package/lib/cjs/nginx-UrubUbn1.js +0 -166
  216. package/lib/cjs/nginx-UrubUbn1.js.map +0 -1
  217. package/lib/cjs/nsis-c2AYwqyy.js +0 -83
  218. package/lib/cjs/nsis-c2AYwqyy.js.map +0 -1
  219. package/lib/cjs/ntriples-N1nwiheD.js +0 -144
  220. package/lib/cjs/ntriples-N1nwiheD.js.map +0 -1
  221. package/lib/cjs/octave-ElonStfZ.js +0 -115
  222. package/lib/cjs/octave-ElonStfZ.js.map +0 -1
  223. package/lib/cjs/oz-7VQTnCfu.js +0 -238
  224. package/lib/cjs/oz-7VQTnCfu.js.map +0 -1
  225. package/lib/cjs/pascal-yq2Cb88Q.js +0 -127
  226. package/lib/cjs/pascal-yq2Cb88Q.js.map +0 -1
  227. package/lib/cjs/perl-hJq4byS9.js +0 -822
  228. package/lib/cjs/perl-hJq4byS9.js.map +0 -1
  229. package/lib/cjs/pig-2syuOlAa.js +0 -152
  230. package/lib/cjs/pig-2syuOlAa.js.map +0 -1
  231. package/lib/cjs/powershell-NDwxuSDg.js +0 -384
  232. package/lib/cjs/powershell-NDwxuSDg.js.map +0 -1
  233. package/lib/cjs/properties-wacODxDJ.js +0 -65
  234. package/lib/cjs/properties-wacODxDJ.js.map +0 -1
  235. package/lib/cjs/protobuf-zVHZwskk.js +0 -57
  236. package/lib/cjs/protobuf-zVHZwskk.js.map +0 -1
  237. package/lib/cjs/puppet-koQikqO-.js +0 -208
  238. package/lib/cjs/puppet-koQikqO-.js.map +0 -1
  239. package/lib/cjs/python-P3UsKHbj.js +0 -394
  240. package/lib/cjs/python-P3UsKHbj.js.map +0 -1
  241. package/lib/cjs/q-Z_d2uXoA.js +0 -126
  242. package/lib/cjs/q-Z_d2uXoA.js.map +0 -1
  243. package/lib/cjs/r-J6Jl9z1i.js +0 -177
  244. package/lib/cjs/r-J6Jl9z1i.js.map +0 -1
  245. package/lib/cjs/rpm-6C0Omumu.js +0 -93
  246. package/lib/cjs/rpm-6C0Omumu.js.map +0 -1
  247. package/lib/cjs/ruby-POVyUmsb.js +0 -290
  248. package/lib/cjs/ruby-POVyUmsb.js.map +0 -1
  249. package/lib/cjs/sas-vDtpSmFr.js +0 -271
  250. package/lib/cjs/sas-vDtpSmFr.js.map +0 -1
  251. package/lib/cjs/schema-RVrwDDcq.js +0 -74
  252. package/lib/cjs/schema-RVrwDDcq.js.map +0 -1
  253. package/lib/cjs/scheme-5AA5BH7S.js +0 -266
  254. package/lib/cjs/scheme-5AA5BH7S.js.map +0 -1
  255. package/lib/cjs/shell-_ztDMiW6.js +0 -148
  256. package/lib/cjs/shell-_ztDMiW6.js.map +0 -1
  257. package/lib/cjs/sieve-R_vzlbvH.js +0 -181
  258. package/lib/cjs/sieve-R_vzlbvH.js.map +0 -1
  259. package/lib/cjs/simple-mode-ZwmNbV0h.js +0 -138
  260. package/lib/cjs/simple-mode-ZwmNbV0h.js.map +0 -1
  261. package/lib/cjs/smalltalk-dWLp5zN8.js +0 -156
  262. package/lib/cjs/smalltalk-dWLp5zN8.js.map +0 -1
  263. package/lib/cjs/solr-wSmvjKI8.js +0 -83
  264. package/lib/cjs/solr-wSmvjKI8.js.map +0 -1
  265. package/lib/cjs/sparql-GNU_0xKB.js +0 -173
  266. package/lib/cjs/sparql-GNU_0xKB.js.map +0 -1
  267. package/lib/cjs/spreadsheet-BiqYLk6M.js +0 -101
  268. package/lib/cjs/spreadsheet-BiqYLk6M.js.map +0 -1
  269. package/lib/cjs/sql-9GpHBPsC.js +0 -497
  270. package/lib/cjs/sql-9GpHBPsC.js.map +0 -1
  271. package/lib/cjs/stex-1V41CNLk.js +0 -250
  272. package/lib/cjs/stex-1V41CNLk.js.map +0 -1
  273. package/lib/cjs/stylus-H6hn9z_G.js +0 -753
  274. package/lib/cjs/stylus-H6hn9z_G.js.map +0 -1
  275. package/lib/cjs/swift-Xv5f8zgN.js +0 -205
  276. package/lib/cjs/swift-Xv5f8zgN.js.map +0 -1
  277. package/lib/cjs/tcl-LI-LOw_t.js +0 -128
  278. package/lib/cjs/tcl-LI-LOw_t.js.map +0 -1
  279. package/lib/cjs/textile-3NvRPUgg.js +0 -444
  280. package/lib/cjs/textile-3NvRPUgg.js.map +0 -1
  281. package/lib/cjs/tiddlywiki-PkMzy8_R.js +0 -281
  282. package/lib/cjs/tiddlywiki-PkMzy8_R.js.map +0 -1
  283. package/lib/cjs/tiki-Zk_GnEC8.js +0 -292
  284. package/lib/cjs/tiki-Zk_GnEC8.js.map +0 -1
  285. package/lib/cjs/todoList-Ze4FLMlx.js.map +0 -1
  286. package/lib/cjs/toml-36gJ0YCq.js +0 -78
  287. package/lib/cjs/toml-36gJ0YCq.js.map +0 -1
  288. package/lib/cjs/tooltip-plugin--lhebztC.js +0 -191
  289. package/lib/cjs/tooltip-plugin--lhebztC.js.map +0 -1
  290. package/lib/cjs/troff-RLZ_o61o.js +0 -67
  291. package/lib/cjs/troff-RLZ_o61o.js.map +0 -1
  292. package/lib/cjs/ttcn-cfg-twaoJYvf.js +0 -204
  293. package/lib/cjs/ttcn-cfg-twaoJYvf.js.map +0 -1
  294. package/lib/cjs/ttcn-kGwvGb2v.js +0 -260
  295. package/lib/cjs/ttcn-kGwvGb2v.js.map +0 -1
  296. package/lib/cjs/turtle-nnevat7b.js +0 -144
  297. package/lib/cjs/turtle-nnevat7b.js.map +0 -1
  298. package/lib/cjs/vb-fO_I9s3s.js +0 -252
  299. package/lib/cjs/vb-fO_I9s3s.js.map +0 -1
  300. package/lib/cjs/vbscript-HXnn40y4.js +0 -324
  301. package/lib/cjs/vbscript-HXnn40y4.js.map +0 -1
  302. package/lib/cjs/velocity-Wn-ZfFzr.js +0 -189
  303. package/lib/cjs/velocity-Wn-ZfFzr.js.map +0 -1
  304. package/lib/cjs/verilog-y1ev34z6.js +0 -569
  305. package/lib/cjs/verilog-y1ev34z6.js.map +0 -1
  306. package/lib/cjs/vhdl-LF0oeXxc.js +0 -177
  307. package/lib/cjs/vhdl-LF0oeXxc.js.map +0 -1
  308. package/lib/cjs/webidl-6kI5KbeC.js +0 -182
  309. package/lib/cjs/webidl-6kI5KbeC.js.map +0 -1
  310. package/lib/cjs/xquery-BavrmwsO.js +0 -428
  311. package/lib/cjs/xquery-BavrmwsO.js.map +0 -1
  312. package/lib/cjs/yacas-1g_AbTrl.js +0 -185
  313. package/lib/cjs/yacas-1g_AbTrl.js.map +0 -1
  314. package/lib/cjs/z80-QYzKAAp7.js +0 -106
  315. package/lib/cjs/z80-QYzKAAp7.js.map +0 -1
  316. package/lib/esm/_view-IlZC8FA6.js +0 -25
  317. package/lib/esm/_view-IlZC8FA6.js.map +0 -1
  318. package/lib/esm/apl-eHQxyJFn.js +0 -143
  319. package/lib/esm/apl-eHQxyJFn.js.map +0 -1
  320. package/lib/esm/asciiarmor-Z-IGYCI4.js +0 -57
  321. package/lib/esm/asciiarmor-Z-IGYCI4.js.map +0 -1
  322. package/lib/esm/asn1-gF7x-q1y.js +0 -193
  323. package/lib/esm/asn1-gF7x-q1y.js.map +0 -1
  324. package/lib/esm/asterisk-swk20ftp.js +0 -188
  325. package/lib/esm/asterisk-swk20ftp.js.map +0 -1
  326. package/lib/esm/brainfuck-IFQdiQoR.js +0 -71
  327. package/lib/esm/brainfuck-IFQdiQoR.js.map +0 -1
  328. package/lib/esm/clike-q3hUF2Cx.js +0 -1019
  329. package/lib/esm/clike-q3hUF2Cx.js.map +0 -1
  330. package/lib/esm/clojure-I2Krbr2M.js +0 -275
  331. package/lib/esm/clojure-I2Krbr2M.js.map +0 -1
  332. package/lib/esm/clsx-RxCLxYpD.js +0 -4
  333. package/lib/esm/clsx-RxCLxYpD.js.map +0 -1
  334. package/lib/esm/cmake-ewwXLeuZ.js +0 -82
  335. package/lib/esm/cmake-ewwXLeuZ.js.map +0 -1
  336. package/lib/esm/cobol-fpN1nAnR.js +0 -236
  337. package/lib/esm/cobol-fpN1nAnR.js.map +0 -1
  338. package/lib/esm/coffeescript--eTFR-bH.js +0 -330
  339. package/lib/esm/coffeescript--eTFR-bH.js.map +0 -1
  340. package/lib/esm/commonlisp-XLSwVdLc.js +0 -109
  341. package/lib/esm/commonlisp-XLSwVdLc.js.map +0 -1
  342. package/lib/esm/crystal-_r3Aa1_a.js +0 -420
  343. package/lib/esm/crystal-_r3Aa1_a.js.map +0 -1
  344. package/lib/esm/css-hgwYGMKZ.js +0 -848
  345. package/lib/esm/css-hgwYGMKZ.js.map +0 -1
  346. package/lib/esm/cypher-bbJyAa-4.js +0 -123
  347. package/lib/esm/cypher-bbJyAa-4.js.map +0 -1
  348. package/lib/esm/d-5MyulviS.js +0 -206
  349. package/lib/esm/d-5MyulviS.js.map +0 -1
  350. package/lib/esm/diff-neOaT_vk.js +0 -31
  351. package/lib/esm/diff-neOaT_vk.js.map +0 -1
  352. package/lib/esm/dockerfile-lzx42-zz.js +0 -200
  353. package/lib/esm/dockerfile-lzx42-zz.js.map +0 -1
  354. package/lib/esm/dtd-FmzPLZcQ.js +0 -122
  355. package/lib/esm/dtd-FmzPLZcQ.js.map +0 -1
  356. package/lib/esm/dylan-1HtRK4GO.js +0 -338
  357. package/lib/esm/dylan-1HtRK4GO.js.map +0 -1
  358. package/lib/esm/ebnf-Nz-pnLHy.js +0 -152
  359. package/lib/esm/ebnf-Nz-pnLHy.js.map +0 -1
  360. package/lib/esm/ecl-lQsZhQz0.js +0 -191
  361. package/lib/esm/ecl-lQsZhQz0.js.map +0 -1
  362. package/lib/esm/eiffel-R_HiEkhx.js +0 -147
  363. package/lib/esm/eiffel-R_HiEkhx.js.map +0 -1
  364. package/lib/esm/elm-KYv4VTDg.js +0 -231
  365. package/lib/esm/elm-KYv4VTDg.js.map +0 -1
  366. package/lib/esm/erlang-7YaHCBIe.js +0 -582
  367. package/lib/esm/erlang-7YaHCBIe.js.map +0 -1
  368. package/lib/esm/factor-opBU9aTK.js +0 -66
  369. package/lib/esm/factor-opBU9aTK.js.map +0 -1
  370. package/lib/esm/fcl-jm31FmFz.js +0 -155
  371. package/lib/esm/fcl-jm31FmFz.js.map +0 -1
  372. package/lib/esm/floating-ui.dom-CAYjY8Gv.js +0 -1130
  373. package/lib/esm/floating-ui.dom-CAYjY8Gv.js.map +0 -1
  374. package/lib/esm/forth-5NKbjnWh.js +0 -165
  375. package/lib/esm/forth-5NKbjnWh.js.map +0 -1
  376. package/lib/esm/fortran-dXm_-cb9.js +0 -173
  377. package/lib/esm/fortran-dXm_-cb9.js.map +0 -1
  378. package/lib/esm/gas-nsYVnsy-.js +0 -344
  379. package/lib/esm/gas-nsYVnsy-.js.map +0 -1
  380. package/lib/esm/gherkin-fzKpjm3M.js +0 -148
  381. package/lib/esm/gherkin-fzKpjm3M.js.map +0 -1
  382. package/lib/esm/go-Pn1qh7yl.js +0 -165
  383. package/lib/esm/go-Pn1qh7yl.js.map +0 -1
  384. package/lib/esm/groovy-DZY-8keZ.js +0 -231
  385. package/lib/esm/groovy-DZY-8keZ.js.map +0 -1
  386. package/lib/esm/haskell-JGh2upDd.js +0 -240
  387. package/lib/esm/haskell-JGh2upDd.js.map +0 -1
  388. package/lib/esm/haxe-1hvVK-Fy.js +0 -491
  389. package/lib/esm/haxe-1hvVK-Fy.js.map +0 -1
  390. package/lib/esm/helper-wZAtC67x.js +0 -13
  391. package/lib/esm/helper-wZAtC67x.js.map +0 -1
  392. package/lib/esm/http-mY1M77wn.js +0 -90
  393. package/lib/esm/http-mY1M77wn.js.map +0 -1
  394. package/lib/esm/idl-dy_653wH.js +0 -275
  395. package/lib/esm/idl-dy_653wH.js.map +0 -1
  396. package/lib/esm/index-0-j8Icms.js +0 -384
  397. package/lib/esm/index-0-j8Icms.js.map +0 -1
  398. package/lib/esm/index-1l-61HI-.js +0 -358
  399. package/lib/esm/index-1l-61HI-.js.map +0 -1
  400. package/lib/esm/index-3HeWs5rX.js +0 -440
  401. package/lib/esm/index-3HeWs5rX.js.map +0 -1
  402. package/lib/esm/index-3bDzhU6z.js +0 -759
  403. package/lib/esm/index-3bDzhU6z.js.map +0 -1
  404. package/lib/esm/index-6GrVnloh.js +0 -1027
  405. package/lib/esm/index-6GrVnloh.js.map +0 -1
  406. package/lib/esm/index-8QJbxTYk.js +0 -1145
  407. package/lib/esm/index-8QJbxTYk.js.map +0 -1
  408. package/lib/esm/index-9w_hdnvb.js +0 -532
  409. package/lib/esm/index-9w_hdnvb.js.map +0 -1
  410. package/lib/esm/index-AOoFzBaK.js +0 -53
  411. package/lib/esm/index-AOoFzBaK.js.map +0 -1
  412. package/lib/esm/index-DS7Z4Ach.js +0 -686
  413. package/lib/esm/index-DS7Z4Ach.js.map +0 -1
  414. package/lib/esm/index-LAdX6LsO.js +0 -33805
  415. package/lib/esm/index-LAdX6LsO.js.map +0 -1
  416. package/lib/esm/index-MxgqkRtj.js +0 -125
  417. package/lib/esm/index-MxgqkRtj.js.map +0 -1
  418. package/lib/esm/index-NZ5-xr5_.js +0 -351
  419. package/lib/esm/index-NZ5-xr5_.js.map +0 -1
  420. package/lib/esm/index-OpUb5xP6.js +0 -1872
  421. package/lib/esm/index-OpUb5xP6.js.map +0 -1
  422. package/lib/esm/index-SDPCpsD5.js +0 -461
  423. package/lib/esm/index-SDPCpsD5.js.map +0 -1
  424. package/lib/esm/index-VP76m4nW.js +0 -157
  425. package/lib/esm/index-VP76m4nW.js.map +0 -1
  426. package/lib/esm/index-Vl0W0S3h.js +0 -259
  427. package/lib/esm/index-Vl0W0S3h.js.map +0 -1
  428. package/lib/esm/index-VoX_n1l_.js +0 -1038
  429. package/lib/esm/index-VoX_n1l_.js.map +0 -1
  430. package/lib/esm/index-XH7OnwZl.js +0 -527
  431. package/lib/esm/index-XH7OnwZl.js.map +0 -1
  432. package/lib/esm/index-Yuj7sNhQ.js +0 -105
  433. package/lib/esm/index-Yuj7sNhQ.js.map +0 -1
  434. package/lib/esm/index-_4fWmRbN.js +0 -206
  435. package/lib/esm/index-_4fWmRbN.js.map +0 -1
  436. package/lib/esm/index-bexsWrgs.js +0 -153
  437. package/lib/esm/index-bexsWrgs.js.map +0 -1
  438. package/lib/esm/index-chrnjY1D.js +0 -470
  439. package/lib/esm/index-chrnjY1D.js.map +0 -1
  440. package/lib/esm/index-eqd5wtjX.js +0 -393
  441. package/lib/esm/index-eqd5wtjX.js.map +0 -1
  442. package/lib/esm/index-g_3dzLYU.js +0 -200
  443. package/lib/esm/index-g_3dzLYU.js.map +0 -1
  444. package/lib/esm/index-grT-Kuf2.js +0 -78
  445. package/lib/esm/index-grT-Kuf2.js.map +0 -1
  446. package/lib/esm/index-hF04phbf.js +0 -189
  447. package/lib/esm/index-hF04phbf.js.map +0 -1
  448. package/lib/esm/index-i79QMXpJ.js +0 -25654
  449. package/lib/esm/index-i79QMXpJ.js.map +0 -1
  450. package/lib/esm/index-rvOBAXap.js +0 -2512
  451. package/lib/esm/index-rvOBAXap.js.map +0 -1
  452. package/lib/esm/index-uP9BKsTM.js +0 -446
  453. package/lib/esm/index-uP9BKsTM.js.map +0 -1
  454. package/lib/esm/index-ueQQMSgm.js +0 -1351
  455. package/lib/esm/index-ueQQMSgm.js.map +0 -1
  456. package/lib/esm/index-x8SyiPMC.js +0 -401
  457. package/lib/esm/index-x8SyiPMC.js.map +0 -1
  458. package/lib/esm/index-zrQXXSXm.js +0 -115
  459. package/lib/esm/index-zrQXXSXm.js.map +0 -1
  460. package/lib/esm/javascript-TMTz-YQH.js +0 -923
  461. package/lib/esm/javascript-TMTz-YQH.js.map +0 -1
  462. package/lib/esm/jinja2-sRIdliZK.js +0 -172
  463. package/lib/esm/jinja2-sRIdliZK.js.map +0 -1
  464. package/lib/esm/julia-fK0wmpGL.js +0 -370
  465. package/lib/esm/julia-fK0wmpGL.js.map +0 -1
  466. package/lib/esm/livescript-FRbAot3D.js +0 -260
  467. package/lib/esm/livescript-FRbAot3D.js.map +0 -1
  468. package/lib/esm/lua-t4FHEjvK.js +0 -138
  469. package/lib/esm/lua-t4FHEjvK.js.map +0 -1
  470. package/lib/esm/mathematica-sn_KGlYj.js +0 -154
  471. package/lib/esm/mathematica-sn_KGlYj.js.map +0 -1
  472. package/lib/esm/mbox-KvVC319E.js +0 -115
  473. package/lib/esm/mbox-KvVC319E.js.map +0 -1
  474. package/lib/esm/mirc-PzJ0zKSk.js +0 -177
  475. package/lib/esm/mirc-PzJ0zKSk.js.map +0 -1
  476. package/lib/esm/mllike-ZK411xkN.js +0 -347
  477. package/lib/esm/mllike-ZK411xkN.js.map +0 -1
  478. package/lib/esm/modelica-ZaHlRCbp.js +0 -193
  479. package/lib/esm/modelica-ZaHlRCbp.js.map +0 -1
  480. package/lib/esm/mscgen-Kkq4o4Zm.js +0 -150
  481. package/lib/esm/mscgen-Kkq4o4Zm.js.map +0 -1
  482. package/lib/esm/mumps-M8a87-rl.js +0 -130
  483. package/lib/esm/mumps-M8a87-rl.js.map +0 -1
  484. package/lib/esm/nginx-2LJIX23E.js +0 -164
  485. package/lib/esm/nginx-2LJIX23E.js.map +0 -1
  486. package/lib/esm/nsis-zvfFgMLi.js +0 -81
  487. package/lib/esm/nsis-zvfFgMLi.js.map +0 -1
  488. package/lib/esm/ntriples-tVkHy5bk.js +0 -142
  489. package/lib/esm/ntriples-tVkHy5bk.js.map +0 -1
  490. package/lib/esm/octave-mE4T5MF5.js +0 -113
  491. package/lib/esm/octave-mE4T5MF5.js.map +0 -1
  492. package/lib/esm/oz-q-LCsuVg.js +0 -236
  493. package/lib/esm/oz-q-LCsuVg.js.map +0 -1
  494. package/lib/esm/pascal-0IgUAn4C.js +0 -125
  495. package/lib/esm/pascal-0IgUAn4C.js.map +0 -1
  496. package/lib/esm/perl-AqxdYGac.js +0 -820
  497. package/lib/esm/perl-AqxdYGac.js.map +0 -1
  498. package/lib/esm/pig-ESM-IjQj.js +0 -150
  499. package/lib/esm/pig-ESM-IjQj.js.map +0 -1
  500. package/lib/esm/powershell-CLFP0L55.js +0 -382
  501. package/lib/esm/powershell-CLFP0L55.js.map +0 -1
  502. package/lib/esm/properties-oWHNzvb9.js +0 -63
  503. package/lib/esm/properties-oWHNzvb9.js.map +0 -1
  504. package/lib/esm/protobuf-c7eMmdcc.js +0 -55
  505. package/lib/esm/protobuf-c7eMmdcc.js.map +0 -1
  506. package/lib/esm/puppet-FjzvdRJr.js +0 -206
  507. package/lib/esm/puppet-FjzvdRJr.js.map +0 -1
  508. package/lib/esm/python-3Pv0tnvt.js +0 -390
  509. package/lib/esm/python-3Pv0tnvt.js.map +0 -1
  510. package/lib/esm/q-IImW8da6.js +0 -124
  511. package/lib/esm/q-IImW8da6.js.map +0 -1
  512. package/lib/esm/r-CnEkTvR0.js +0 -175
  513. package/lib/esm/r-CnEkTvR0.js.map +0 -1
  514. package/lib/esm/rpm-Q55-fEHj.js +0 -90
  515. package/lib/esm/rpm-Q55-fEHj.js.map +0 -1
  516. package/lib/esm/ruby-zhaGB3Kh.js +0 -288
  517. package/lib/esm/ruby-zhaGB3Kh.js.map +0 -1
  518. package/lib/esm/sas-Ur9jZIOV.js +0 -269
  519. package/lib/esm/sas-Ur9jZIOV.js.map +0 -1
  520. package/lib/esm/schema-JWJqD9qa.js +0 -71
  521. package/lib/esm/schema-JWJqD9qa.js.map +0 -1
  522. package/lib/esm/scheme-daT5-Rya.js +0 -264
  523. package/lib/esm/scheme-daT5-Rya.js.map +0 -1
  524. package/lib/esm/shell-cwFL0AYP.js +0 -146
  525. package/lib/esm/shell-cwFL0AYP.js.map +0 -1
  526. package/lib/esm/sieve-MlNXFFUq.js +0 -179
  527. package/lib/esm/sieve-MlNXFFUq.js.map +0 -1
  528. package/lib/esm/simple-mode-m1rsX7Gw.js +0 -136
  529. package/lib/esm/simple-mode-m1rsX7Gw.js.map +0 -1
  530. package/lib/esm/smalltalk-xrQICp9e.js +0 -154
  531. package/lib/esm/smalltalk-xrQICp9e.js.map +0 -1
  532. package/lib/esm/solr-PU3oPgQz.js +0 -81
  533. package/lib/esm/solr-PU3oPgQz.js.map +0 -1
  534. package/lib/esm/sparql--u8NRBii.js +0 -171
  535. package/lib/esm/sparql--u8NRBii.js.map +0 -1
  536. package/lib/esm/spreadsheet-QCp0LifX.js +0 -99
  537. package/lib/esm/spreadsheet-QCp0LifX.js.map +0 -1
  538. package/lib/esm/sql-dsGfl64h.js +0 -482
  539. package/lib/esm/sql-dsGfl64h.js.map +0 -1
  540. package/lib/esm/stex-WcLBzvkD.js +0 -247
  541. package/lib/esm/stex-WcLBzvkD.js.map +0 -1
  542. package/lib/esm/stylus--A5XAqOX.js +0 -751
  543. package/lib/esm/stylus--A5XAqOX.js.map +0 -1
  544. package/lib/esm/swift-qAm73i7G.js +0 -203
  545. package/lib/esm/swift-qAm73i7G.js.map +0 -1
  546. package/lib/esm/tcl-Kdc7qxc-.js +0 -126
  547. package/lib/esm/tcl-Kdc7qxc-.js.map +0 -1
  548. package/lib/esm/textile--sz8UrIz.js +0 -442
  549. package/lib/esm/textile--sz8UrIz.js.map +0 -1
  550. package/lib/esm/tiddlywiki-xNXTeBlQ.js +0 -279
  551. package/lib/esm/tiddlywiki-xNXTeBlQ.js.map +0 -1
  552. package/lib/esm/tiki-LCXjrNH3.js +0 -290
  553. package/lib/esm/tiki-LCXjrNH3.js.map +0 -1
  554. package/lib/esm/todoList-M-PGJKde.js.map +0 -1
  555. package/lib/esm/toml-Ac4tlBMn.js +0 -76
  556. package/lib/esm/toml-Ac4tlBMn.js.map +0 -1
  557. package/lib/esm/tooltip-plugin-iw2EQWIG.js +0 -185
  558. package/lib/esm/tooltip-plugin-iw2EQWIG.js.map +0 -1
  559. package/lib/esm/troff-LLW1x1Yz.js +0 -65
  560. package/lib/esm/troff-LLW1x1Yz.js.map +0 -1
  561. package/lib/esm/ttcn-ZYZ9FS3u.js +0 -258
  562. package/lib/esm/ttcn-ZYZ9FS3u.js.map +0 -1
  563. package/lib/esm/ttcn-cfg-qsvf3MfB.js +0 -202
  564. package/lib/esm/ttcn-cfg-qsvf3MfB.js.map +0 -1
  565. package/lib/esm/turtle-wq3TqOth.js +0 -142
  566. package/lib/esm/turtle-wq3TqOth.js.map +0 -1
  567. package/lib/esm/vb-86M_JuNP.js +0 -250
  568. package/lib/esm/vb-86M_JuNP.js.map +0 -1
  569. package/lib/esm/vbscript-GueAeVug.js +0 -321
  570. package/lib/esm/vbscript-GueAeVug.js.map +0 -1
  571. package/lib/esm/velocity-7PW9GXO2.js +0 -187
  572. package/lib/esm/velocity-7PW9GXO2.js.map +0 -1
  573. package/lib/esm/verilog-PXtXH14C.js +0 -566
  574. package/lib/esm/verilog-PXtXH14C.js.map +0 -1
  575. package/lib/esm/vhdl-I8eyK83X.js +0 -175
  576. package/lib/esm/vhdl-I8eyK83X.js.map +0 -1
  577. package/lib/esm/webidl-1f8ATJ66.js +0 -180
  578. package/lib/esm/webidl-1f8ATJ66.js.map +0 -1
  579. package/lib/esm/xquery-IYp28Wx6.js +0 -426
  580. package/lib/esm/xquery-IYp28Wx6.js.map +0 -1
  581. package/lib/esm/yacas-wkENB05f.js +0 -183
  582. package/lib/esm/yacas-wkENB05f.js.map +0 -1
  583. package/lib/esm/z80-GaXiLdiV.js +0 -103
  584. package/lib/esm/z80-GaXiLdiV.js.map +0 -1
@@ -1,1877 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-Jztk6JlP.js');
4
-
5
- /**
6
- A parse stack. These are used internally by the parser to track
7
- parsing progress. They also provide some properties and methods
8
- that external code such as a tokenizer can use to get information
9
- about the parse state.
10
- */
11
- class Stack {
12
- /**
13
- @internal
14
- */
15
- constructor(
16
- /**
17
- The parse that this stack is part of @internal
18
- */
19
- p,
20
- /**
21
- Holds state, input pos, buffer index triplets for all but the
22
- top state @internal
23
- */
24
- stack,
25
- /**
26
- The current parse state @internal
27
- */
28
- state,
29
- // The position at which the next reduce should take place. This
30
- // can be less than `this.pos` when skipped expressions have been
31
- // added to the stack (which should be moved outside of the next
32
- // reduction)
33
- /**
34
- @internal
35
- */
36
- reducePos,
37
- /**
38
- The input position up to which this stack has parsed.
39
- */
40
- pos,
41
- /**
42
- The dynamic score of the stack, including dynamic precedence
43
- and error-recovery penalties
44
- @internal
45
- */
46
- score,
47
- // The output buffer. Holds (type, start, end, size) quads
48
- // representing nodes created by the parser, where `size` is
49
- // amount of buffer array entries covered by this node.
50
- /**
51
- @internal
52
- */
53
- buffer,
54
- // The base offset of the buffer. When stacks are split, the split
55
- // instance shared the buffer history with its parent up to
56
- // `bufferBase`, which is the absolute offset (including the
57
- // offset of previous splits) into the buffer at which this stack
58
- // starts writing.
59
- /**
60
- @internal
61
- */
62
- bufferBase,
63
- /**
64
- @internal
65
- */
66
- curContext,
67
- /**
68
- @internal
69
- */
70
- lookAhead = 0,
71
- // A parent stack from which this was split off, if any. This is
72
- // set up so that it always points to a stack that has some
73
- // additional buffer content, never to a stack with an equal
74
- // `bufferBase`.
75
- /**
76
- @internal
77
- */
78
- parent) {
79
- this.p = p;
80
- this.stack = stack;
81
- this.state = state;
82
- this.reducePos = reducePos;
83
- this.pos = pos;
84
- this.score = score;
85
- this.buffer = buffer;
86
- this.bufferBase = bufferBase;
87
- this.curContext = curContext;
88
- this.lookAhead = lookAhead;
89
- this.parent = parent;
90
- }
91
- /**
92
- @internal
93
- */
94
- toString() {
95
- return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
96
- }
97
- // Start an empty stack
98
- /**
99
- @internal
100
- */
101
- static start(p, state, pos = 0) {
102
- let cx = p.parser.context;
103
- return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
104
- }
105
- /**
106
- The stack's current [context](#lr.ContextTracker) value, if
107
- any. Its type will depend on the context tracker's type
108
- parameter, or it will be `null` if there is no context
109
- tracker.
110
- */
111
- get context() { return this.curContext ? this.curContext.context : null; }
112
- // Push a state onto the stack, tracking its start position as well
113
- // as the buffer base at that point.
114
- /**
115
- @internal
116
- */
117
- pushState(state, start) {
118
- this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
119
- this.state = state;
120
- }
121
- // Apply a reduce action
122
- /**
123
- @internal
124
- */
125
- reduce(action) {
126
- var _a;
127
- let depth = action >> 19 /* Action.ReduceDepthShift */, type = action & 65535 /* Action.ValueMask */;
128
- let { parser } = this.p;
129
- let dPrec = parser.dynamicPrecedence(type);
130
- if (dPrec)
131
- this.score += dPrec;
132
- if (depth == 0) {
133
- this.pushState(parser.getGoto(this.state, type, true), this.reducePos);
134
- // Zero-depth reductions are a special case—they add stuff to
135
- // the stack without popping anything off.
136
- if (type < parser.minRepeatTerm)
137
- this.storeNode(type, this.reducePos, this.reducePos, 4, true);
138
- this.reduceContext(type, this.reducePos);
139
- return;
140
- }
141
- // Find the base index into `this.stack`, content after which will
142
- // be dropped. Note that with `StayFlag` reductions we need to
143
- // consume two extra frames (the dummy parent node for the skipped
144
- // expression and the state that we'll be staying in, which should
145
- // be moved to `this.state`).
146
- let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* Action.StayFlag */ ? 6 : 0);
147
- let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
148
- // This is a kludge to try and detect overly deep left-associative
149
- // trees, which will not increase the parse stack depth and thus
150
- // won't be caught by the regular stack-depth limit check.
151
- if (size >= 2000 /* Recover.MinBigReduction */ && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
152
- if (start == this.p.lastBigReductionStart) {
153
- this.p.bigReductionCount++;
154
- this.p.lastBigReductionSize = size;
155
- }
156
- else if (this.p.lastBigReductionSize < size) {
157
- this.p.bigReductionCount = 1;
158
- this.p.lastBigReductionStart = start;
159
- this.p.lastBigReductionSize = size;
160
- }
161
- }
162
- let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
163
- // Store normal terms or `R -> R R` repeat reductions
164
- if (type < parser.minRepeatTerm || (action & 131072 /* Action.RepeatFlag */)) {
165
- let pos = parser.stateFlag(this.state, 1 /* StateFlag.Skipped */) ? this.pos : this.reducePos;
166
- this.storeNode(type, start, pos, count + 4, true);
167
- }
168
- if (action & 262144 /* Action.StayFlag */) {
169
- this.state = this.stack[base];
170
- }
171
- else {
172
- let baseStateID = this.stack[base - 3];
173
- this.state = parser.getGoto(baseStateID, type, true);
174
- }
175
- while (this.stack.length > base)
176
- this.stack.pop();
177
- this.reduceContext(type, start);
178
- }
179
- // Shift a value into the buffer
180
- /**
181
- @internal
182
- */
183
- storeNode(term, start, end, size = 4, isReduce = false) {
184
- if (term == 0 /* Term.Err */ &&
185
- (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
186
- // Try to omit/merge adjacent error nodes
187
- let cur = this, top = this.buffer.length;
188
- if (top == 0 && cur.parent) {
189
- top = cur.bufferBase - cur.parent.bufferBase;
190
- cur = cur.parent;
191
- }
192
- if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) {
193
- if (start == end)
194
- return;
195
- if (cur.buffer[top - 2] >= start) {
196
- cur.buffer[top - 2] = end;
197
- return;
198
- }
199
- }
200
- }
201
- if (!isReduce || this.pos == end) { // Simple case, just append
202
- this.buffer.push(term, start, end, size);
203
- }
204
- else { // There may be skipped nodes that have to be moved forward
205
- let index = this.buffer.length;
206
- if (index > 0 && this.buffer[index - 4] != 0 /* Term.Err */)
207
- while (index > 0 && this.buffer[index - 2] > end) {
208
- // Move this record forward
209
- this.buffer[index] = this.buffer[index - 4];
210
- this.buffer[index + 1] = this.buffer[index - 3];
211
- this.buffer[index + 2] = this.buffer[index - 2];
212
- this.buffer[index + 3] = this.buffer[index - 1];
213
- index -= 4;
214
- if (size > 4)
215
- size -= 4;
216
- }
217
- this.buffer[index] = term;
218
- this.buffer[index + 1] = start;
219
- this.buffer[index + 2] = end;
220
- this.buffer[index + 3] = size;
221
- }
222
- }
223
- // Apply a shift action
224
- /**
225
- @internal
226
- */
227
- shift(action, type, start, end) {
228
- if (action & 131072 /* Action.GotoFlag */) {
229
- this.pushState(action & 65535 /* Action.ValueMask */, this.pos);
230
- }
231
- else if ((action & 262144 /* Action.StayFlag */) == 0) { // Regular shift
232
- let nextState = action, { parser } = this.p;
233
- if (end > this.pos || type <= parser.maxNode) {
234
- this.pos = end;
235
- if (!parser.stateFlag(nextState, 1 /* StateFlag.Skipped */))
236
- this.reducePos = end;
237
- }
238
- this.pushState(nextState, start);
239
- this.shiftContext(type, start);
240
- if (type <= parser.maxNode)
241
- this.buffer.push(type, start, end, 4);
242
- }
243
- else { // Shift-and-stay, which means this is a skipped token
244
- this.pos = end;
245
- this.shiftContext(type, start);
246
- if (type <= this.p.parser.maxNode)
247
- this.buffer.push(type, start, end, 4);
248
- }
249
- }
250
- // Apply an action
251
- /**
252
- @internal
253
- */
254
- apply(action, next, nextStart, nextEnd) {
255
- if (action & 65536 /* Action.ReduceFlag */)
256
- this.reduce(action);
257
- else
258
- this.shift(action, next, nextStart, nextEnd);
259
- }
260
- // Add a prebuilt (reused) node into the buffer.
261
- /**
262
- @internal
263
- */
264
- useNode(value, next) {
265
- let index = this.p.reused.length - 1;
266
- if (index < 0 || this.p.reused[index] != value) {
267
- this.p.reused.push(value);
268
- index++;
269
- }
270
- let start = this.pos;
271
- this.reducePos = this.pos = start + value.length;
272
- this.pushState(next, start);
273
- this.buffer.push(index, start, this.reducePos, -1 /* size == -1 means this is a reused value */);
274
- if (this.curContext)
275
- this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
276
- }
277
- // Split the stack. Due to the buffer sharing and the fact
278
- // that `this.stack` tends to stay quite shallow, this isn't very
279
- // expensive.
280
- /**
281
- @internal
282
- */
283
- split() {
284
- let parent = this;
285
- let off = parent.buffer.length;
286
- // Because the top of the buffer (after this.pos) may be mutated
287
- // to reorder reductions and skipped tokens, and shared buffers
288
- // should be immutable, this copies any outstanding skipped tokens
289
- // to the new buffer, and puts the base pointer before them.
290
- while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
291
- off -= 4;
292
- let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
293
- // Make sure parent points to an actual parent with content, if there is such a parent.
294
- while (parent && base == parent.bufferBase)
295
- parent = parent.parent;
296
- return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
297
- }
298
- // Try to recover from an error by 'deleting' (ignoring) one token.
299
- /**
300
- @internal
301
- */
302
- recoverByDelete(next, nextEnd) {
303
- let isNode = next <= this.p.parser.maxNode;
304
- if (isNode)
305
- this.storeNode(next, this.pos, nextEnd, 4);
306
- this.storeNode(0 /* Term.Err */, this.pos, nextEnd, isNode ? 8 : 4);
307
- this.pos = this.reducePos = nextEnd;
308
- this.score -= 190 /* Recover.Delete */;
309
- }
310
- /**
311
- Check if the given term would be able to be shifted (optionally
312
- after some reductions) on this stack. This can be useful for
313
- external tokenizers that want to make sure they only provide a
314
- given token when it applies.
315
- */
316
- canShift(term) {
317
- for (let sim = new SimulatedStack(this);;) {
318
- let action = this.p.parser.stateSlot(sim.state, 4 /* ParseState.DefaultReduce */) || this.p.parser.hasAction(sim.state, term);
319
- if (action == 0)
320
- return false;
321
- if ((action & 65536 /* Action.ReduceFlag */) == 0)
322
- return true;
323
- sim.reduce(action);
324
- }
325
- }
326
- // Apply up to Recover.MaxNext recovery actions that conceptually
327
- // inserts some missing token or rule.
328
- /**
329
- @internal
330
- */
331
- recoverByInsert(next) {
332
- if (this.stack.length >= 300 /* Recover.MaxInsertStackDepth */)
333
- return [];
334
- let nextStates = this.p.parser.nextStates(this.state);
335
- if (nextStates.length > 4 /* Recover.MaxNext */ << 1 || this.stack.length >= 120 /* Recover.DampenInsertStackDepth */) {
336
- let best = [];
337
- for (let i = 0, s; i < nextStates.length; i += 2) {
338
- if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
339
- best.push(nextStates[i], s);
340
- }
341
- if (this.stack.length < 120 /* Recover.DampenInsertStackDepth */)
342
- for (let i = 0; best.length < 4 /* Recover.MaxNext */ << 1 && i < nextStates.length; i += 2) {
343
- let s = nextStates[i + 1];
344
- if (!best.some((v, i) => (i & 1) && v == s))
345
- best.push(nextStates[i], s);
346
- }
347
- nextStates = best;
348
- }
349
- let result = [];
350
- for (let i = 0; i < nextStates.length && result.length < 4 /* Recover.MaxNext */; i += 2) {
351
- let s = nextStates[i + 1];
352
- if (s == this.state)
353
- continue;
354
- let stack = this.split();
355
- stack.pushState(s, this.pos);
356
- stack.storeNode(0 /* Term.Err */, stack.pos, stack.pos, 4, true);
357
- stack.shiftContext(nextStates[i], this.pos);
358
- stack.reducePos = this.pos;
359
- stack.score -= 200 /* Recover.Insert */;
360
- result.push(stack);
361
- }
362
- return result;
363
- }
364
- // Force a reduce, if possible. Return false if that can't
365
- // be done.
366
- /**
367
- @internal
368
- */
369
- forceReduce() {
370
- let { parser } = this.p;
371
- let reduce = parser.stateSlot(this.state, 5 /* ParseState.ForcedReduce */);
372
- if ((reduce & 65536 /* Action.ReduceFlag */) == 0)
373
- return false;
374
- if (!parser.validAction(this.state, reduce)) {
375
- let depth = reduce >> 19 /* Action.ReduceDepthShift */, term = reduce & 65535 /* Action.ValueMask */;
376
- let target = this.stack.length - depth * 3;
377
- if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) {
378
- let backup = this.findForcedReduction();
379
- if (backup == null)
380
- return false;
381
- reduce = backup;
382
- }
383
- this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
384
- this.score -= 100 /* Recover.Reduce */;
385
- }
386
- this.reducePos = this.pos;
387
- this.reduce(reduce);
388
- return true;
389
- }
390
- /**
391
- Try to scan through the automaton to find some kind of reduction
392
- that can be applied. Used when the regular ForcedReduce field
393
- isn't a valid action. @internal
394
- */
395
- findForcedReduction() {
396
- let { parser } = this.p, seen = [];
397
- let explore = (state, depth) => {
398
- if (seen.includes(state))
399
- return;
400
- seen.push(state);
401
- return parser.allActions(state, (action) => {
402
- if (action & (262144 /* Action.StayFlag */ | 131072 /* Action.GotoFlag */)) ;
403
- else if (action & 65536 /* Action.ReduceFlag */) {
404
- let rDepth = (action >> 19 /* Action.ReduceDepthShift */) - depth;
405
- if (rDepth > 1) {
406
- let term = action & 65535 /* Action.ValueMask */, target = this.stack.length - rDepth * 3;
407
- if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0)
408
- return (rDepth << 19 /* Action.ReduceDepthShift */) | 65536 /* Action.ReduceFlag */ | term;
409
- }
410
- }
411
- else {
412
- let found = explore(action, depth + 1);
413
- if (found != null)
414
- return found;
415
- }
416
- });
417
- };
418
- return explore(this.state, 0);
419
- }
420
- /**
421
- @internal
422
- */
423
- forceAll() {
424
- while (!this.p.parser.stateFlag(this.state, 2 /* StateFlag.Accepting */)) {
425
- if (!this.forceReduce()) {
426
- this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
427
- break;
428
- }
429
- }
430
- return this;
431
- }
432
- /**
433
- Check whether this state has no further actions (assumed to be a direct descendant of the
434
- top state, since any other states must be able to continue
435
- somehow). @internal
436
- */
437
- get deadEnd() {
438
- if (this.stack.length != 3)
439
- return false;
440
- let { parser } = this.p;
441
- return parser.data[parser.stateSlot(this.state, 1 /* ParseState.Actions */)] == 65535 /* Seq.End */ &&
442
- !parser.stateSlot(this.state, 4 /* ParseState.DefaultReduce */);
443
- }
444
- /**
445
- Restart the stack (put it back in its start state). Only safe
446
- when this.stack.length == 3 (state is directly below the top
447
- state). @internal
448
- */
449
- restart() {
450
- this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
451
- this.state = this.stack[0];
452
- this.stack.length = 0;
453
- }
454
- /**
455
- @internal
456
- */
457
- sameState(other) {
458
- if (this.state != other.state || this.stack.length != other.stack.length)
459
- return false;
460
- for (let i = 0; i < this.stack.length; i += 3)
461
- if (this.stack[i] != other.stack[i])
462
- return false;
463
- return true;
464
- }
465
- /**
466
- Get the parser used by this stack.
467
- */
468
- get parser() { return this.p.parser; }
469
- /**
470
- Test whether a given dialect (by numeric ID, as exported from
471
- the terms file) is enabled.
472
- */
473
- dialectEnabled(dialectID) { return this.p.parser.dialect.flags[dialectID]; }
474
- shiftContext(term, start) {
475
- if (this.curContext)
476
- this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
477
- }
478
- reduceContext(term, start) {
479
- if (this.curContext)
480
- this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
481
- }
482
- /**
483
- @internal
484
- */
485
- emitContext() {
486
- let last = this.buffer.length - 1;
487
- if (last < 0 || this.buffer[last] != -3)
488
- this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
489
- }
490
- /**
491
- @internal
492
- */
493
- emitLookAhead() {
494
- let last = this.buffer.length - 1;
495
- if (last < 0 || this.buffer[last] != -4)
496
- this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
497
- }
498
- updateContext(context) {
499
- if (context != this.curContext.context) {
500
- let newCx = new StackContext(this.curContext.tracker, context);
501
- if (newCx.hash != this.curContext.hash)
502
- this.emitContext();
503
- this.curContext = newCx;
504
- }
505
- }
506
- /**
507
- @internal
508
- */
509
- setLookAhead(lookAhead) {
510
- if (lookAhead > this.lookAhead) {
511
- this.emitLookAhead();
512
- this.lookAhead = lookAhead;
513
- }
514
- }
515
- /**
516
- @internal
517
- */
518
- close() {
519
- if (this.curContext && this.curContext.tracker.strict)
520
- this.emitContext();
521
- if (this.lookAhead > 0)
522
- this.emitLookAhead();
523
- }
524
- }
525
- class StackContext {
526
- constructor(tracker, context) {
527
- this.tracker = tracker;
528
- this.context = context;
529
- this.hash = tracker.strict ? tracker.hash(context) : 0;
530
- }
531
- }
532
- // Used to cheaply run some reductions to scan ahead without mutating
533
- // an entire stack
534
- class SimulatedStack {
535
- constructor(start) {
536
- this.start = start;
537
- this.state = start.state;
538
- this.stack = start.stack;
539
- this.base = this.stack.length;
540
- }
541
- reduce(action) {
542
- let term = action & 65535 /* Action.ValueMask */, depth = action >> 19 /* Action.ReduceDepthShift */;
543
- if (depth == 0) {
544
- if (this.stack == this.start.stack)
545
- this.stack = this.stack.slice();
546
- this.stack.push(this.state, 0, 0);
547
- this.base += 3;
548
- }
549
- else {
550
- this.base -= (depth - 1) * 3;
551
- }
552
- let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
553
- this.state = goto;
554
- }
555
- }
556
- // This is given to `Tree.build` to build a buffer, and encapsulates
557
- // the parent-stack-walking necessary to read the nodes.
558
- class StackBufferCursor {
559
- constructor(stack, pos, index) {
560
- this.stack = stack;
561
- this.pos = pos;
562
- this.index = index;
563
- this.buffer = stack.buffer;
564
- if (this.index == 0)
565
- this.maybeNext();
566
- }
567
- static create(stack, pos = stack.bufferBase + stack.buffer.length) {
568
- return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
569
- }
570
- maybeNext() {
571
- let next = this.stack.parent;
572
- if (next != null) {
573
- this.index = this.stack.bufferBase - next.bufferBase;
574
- this.stack = next;
575
- this.buffer = next.buffer;
576
- }
577
- }
578
- get id() { return this.buffer[this.index - 4]; }
579
- get start() { return this.buffer[this.index - 3]; }
580
- get end() { return this.buffer[this.index - 2]; }
581
- get size() { return this.buffer[this.index - 1]; }
582
- next() {
583
- this.index -= 4;
584
- this.pos -= 4;
585
- if (this.index == 0)
586
- this.maybeNext();
587
- }
588
- fork() {
589
- return new StackBufferCursor(this.stack, this.pos, this.index);
590
- }
591
- }
592
-
593
- // See lezer-generator/src/encode.ts for comments about the encoding
594
- // used here
595
- function decodeArray(input, Type = Uint16Array) {
596
- if (typeof input != "string")
597
- return input;
598
- let array = null;
599
- for (let pos = 0, out = 0; pos < input.length;) {
600
- let value = 0;
601
- for (;;) {
602
- let next = input.charCodeAt(pos++), stop = false;
603
- if (next == 126 /* Encode.BigValCode */) {
604
- value = 65535 /* Encode.BigVal */;
605
- break;
606
- }
607
- if (next >= 92 /* Encode.Gap2 */)
608
- next--;
609
- if (next >= 34 /* Encode.Gap1 */)
610
- next--;
611
- let digit = next - 32 /* Encode.Start */;
612
- if (digit >= 46 /* Encode.Base */) {
613
- digit -= 46 /* Encode.Base */;
614
- stop = true;
615
- }
616
- value += digit;
617
- if (stop)
618
- break;
619
- value *= 46 /* Encode.Base */;
620
- }
621
- if (array)
622
- array[out++] = value;
623
- else
624
- array = new Type(value);
625
- }
626
- return array;
627
- }
628
-
629
- class CachedToken {
630
- constructor() {
631
- this.start = -1;
632
- this.value = -1;
633
- this.end = -1;
634
- this.extended = -1;
635
- this.lookAhead = 0;
636
- this.mask = 0;
637
- this.context = 0;
638
- }
639
- }
640
- const nullToken = new CachedToken;
641
- /**
642
- [Tokenizers](#lr.ExternalTokenizer) interact with the input
643
- through this interface. It presents the input as a stream of
644
- characters, tracking lookahead and hiding the complexity of
645
- [ranges](#common.Parser.parse^ranges) from tokenizer code.
646
- */
647
- class InputStream {
648
- /**
649
- @internal
650
- */
651
- constructor(
652
- /**
653
- @internal
654
- */
655
- input,
656
- /**
657
- @internal
658
- */
659
- ranges) {
660
- this.input = input;
661
- this.ranges = ranges;
662
- /**
663
- @internal
664
- */
665
- this.chunk = "";
666
- /**
667
- @internal
668
- */
669
- this.chunkOff = 0;
670
- /**
671
- Backup chunk
672
- */
673
- this.chunk2 = "";
674
- this.chunk2Pos = 0;
675
- /**
676
- The character code of the next code unit in the input, or -1
677
- when the stream is at the end of the input.
678
- */
679
- this.next = -1;
680
- /**
681
- @internal
682
- */
683
- this.token = nullToken;
684
- this.rangeIndex = 0;
685
- this.pos = this.chunkPos = ranges[0].from;
686
- this.range = ranges[0];
687
- this.end = ranges[ranges.length - 1].to;
688
- this.readNext();
689
- }
690
- /**
691
- @internal
692
- */
693
- resolveOffset(offset, assoc) {
694
- let range = this.range, index = this.rangeIndex;
695
- let pos = this.pos + offset;
696
- while (pos < range.from) {
697
- if (!index)
698
- return null;
699
- let next = this.ranges[--index];
700
- pos -= range.from - next.to;
701
- range = next;
702
- }
703
- while (assoc < 0 ? pos > range.to : pos >= range.to) {
704
- if (index == this.ranges.length - 1)
705
- return null;
706
- let next = this.ranges[++index];
707
- pos += next.from - range.to;
708
- range = next;
709
- }
710
- return pos;
711
- }
712
- /**
713
- @internal
714
- */
715
- clipPos(pos) {
716
- if (pos >= this.range.from && pos < this.range.to)
717
- return pos;
718
- for (let range of this.ranges)
719
- if (range.to > pos)
720
- return Math.max(pos, range.from);
721
- return this.end;
722
- }
723
- /**
724
- Look at a code unit near the stream position. `.peek(0)` equals
725
- `.next`, `.peek(-1)` gives you the previous character, and so
726
- on.
727
-
728
- Note that looking around during tokenizing creates dependencies
729
- on potentially far-away content, which may reduce the
730
- effectiveness incremental parsing—when looking forward—or even
731
- cause invalid reparses when looking backward more than 25 code
732
- units, since the library does not track lookbehind.
733
- */
734
- peek(offset) {
735
- let idx = this.chunkOff + offset, pos, result;
736
- if (idx >= 0 && idx < this.chunk.length) {
737
- pos = this.pos + offset;
738
- result = this.chunk.charCodeAt(idx);
739
- }
740
- else {
741
- let resolved = this.resolveOffset(offset, 1);
742
- if (resolved == null)
743
- return -1;
744
- pos = resolved;
745
- if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
746
- result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
747
- }
748
- else {
749
- let i = this.rangeIndex, range = this.range;
750
- while (range.to <= pos)
751
- range = this.ranges[++i];
752
- this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
753
- if (pos + this.chunk2.length > range.to)
754
- this.chunk2 = this.chunk2.slice(0, range.to - pos);
755
- result = this.chunk2.charCodeAt(0);
756
- }
757
- }
758
- if (pos >= this.token.lookAhead)
759
- this.token.lookAhead = pos + 1;
760
- return result;
761
- }
762
- /**
763
- Accept a token. By default, the end of the token is set to the
764
- current stream position, but you can pass an offset (relative to
765
- the stream position) to change that.
766
- */
767
- acceptToken(token, endOffset = 0) {
768
- let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
769
- if (end == null || end < this.token.start)
770
- throw new RangeError("Token end out of bounds");
771
- this.token.value = token;
772
- this.token.end = end;
773
- }
774
- /**
775
- Accept a token ending at a specific given position.
776
- */
777
- acceptTokenTo(token, endPos) {
778
- this.token.value = token;
779
- this.token.end = endPos;
780
- }
781
- getChunk() {
782
- if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
783
- let { chunk, chunkPos } = this;
784
- this.chunk = this.chunk2;
785
- this.chunkPos = this.chunk2Pos;
786
- this.chunk2 = chunk;
787
- this.chunk2Pos = chunkPos;
788
- this.chunkOff = this.pos - this.chunkPos;
789
- }
790
- else {
791
- this.chunk2 = this.chunk;
792
- this.chunk2Pos = this.chunkPos;
793
- let nextChunk = this.input.chunk(this.pos);
794
- let end = this.pos + nextChunk.length;
795
- this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
796
- this.chunkPos = this.pos;
797
- this.chunkOff = 0;
798
- }
799
- }
800
- readNext() {
801
- if (this.chunkOff >= this.chunk.length) {
802
- this.getChunk();
803
- if (this.chunkOff == this.chunk.length)
804
- return this.next = -1;
805
- }
806
- return this.next = this.chunk.charCodeAt(this.chunkOff);
807
- }
808
- /**
809
- Move the stream forward N (defaults to 1) code units. Returns
810
- the new value of [`next`](#lr.InputStream.next).
811
- */
812
- advance(n = 1) {
813
- this.chunkOff += n;
814
- while (this.pos + n >= this.range.to) {
815
- if (this.rangeIndex == this.ranges.length - 1)
816
- return this.setDone();
817
- n -= this.range.to - this.pos;
818
- this.range = this.ranges[++this.rangeIndex];
819
- this.pos = this.range.from;
820
- }
821
- this.pos += n;
822
- if (this.pos >= this.token.lookAhead)
823
- this.token.lookAhead = this.pos + 1;
824
- return this.readNext();
825
- }
826
- setDone() {
827
- this.pos = this.chunkPos = this.end;
828
- this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
829
- this.chunk = "";
830
- return this.next = -1;
831
- }
832
- /**
833
- @internal
834
- */
835
- reset(pos, token) {
836
- if (token) {
837
- this.token = token;
838
- token.start = pos;
839
- token.lookAhead = pos + 1;
840
- token.value = token.extended = -1;
841
- }
842
- else {
843
- this.token = nullToken;
844
- }
845
- if (this.pos != pos) {
846
- this.pos = pos;
847
- if (pos == this.end) {
848
- this.setDone();
849
- return this;
850
- }
851
- while (pos < this.range.from)
852
- this.range = this.ranges[--this.rangeIndex];
853
- while (pos >= this.range.to)
854
- this.range = this.ranges[++this.rangeIndex];
855
- if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
856
- this.chunkOff = pos - this.chunkPos;
857
- }
858
- else {
859
- this.chunk = "";
860
- this.chunkOff = 0;
861
- }
862
- this.readNext();
863
- }
864
- return this;
865
- }
866
- /**
867
- @internal
868
- */
869
- read(from, to) {
870
- if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
871
- return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
872
- if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
873
- return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
874
- if (from >= this.range.from && to <= this.range.to)
875
- return this.input.read(from, to);
876
- let result = "";
877
- for (let r of this.ranges) {
878
- if (r.from >= to)
879
- break;
880
- if (r.to > from)
881
- result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
882
- }
883
- return result;
884
- }
885
- }
886
- /**
887
- @internal
888
- */
889
- class TokenGroup {
890
- constructor(data, id) {
891
- this.data = data;
892
- this.id = id;
893
- }
894
- token(input, stack) {
895
- let { parser } = stack.p;
896
- readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
897
- }
898
- }
899
- TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
900
- /**
901
- @hide
902
- */
903
- class LocalTokenGroup {
904
- constructor(data, precTable, elseToken) {
905
- this.precTable = precTable;
906
- this.elseToken = elseToken;
907
- this.data = typeof data == "string" ? decodeArray(data) : data;
908
- }
909
- token(input, stack) {
910
- let start = input.pos, skipped = 0;
911
- for (;;) {
912
- let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
913
- readToken(this.data, input, stack, 0, this.data, this.precTable);
914
- if (input.token.value > -1)
915
- break;
916
- if (this.elseToken == null)
917
- return;
918
- if (!atEof)
919
- skipped++;
920
- if (nextPos == null)
921
- break;
922
- input.reset(nextPos, input.token);
923
- }
924
- if (skipped) {
925
- input.reset(start, input.token);
926
- input.acceptToken(this.elseToken, skipped);
927
- }
928
- }
929
- }
930
- LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
931
- /**
932
- `@external tokens` declarations in the grammar should resolve to
933
- an instance of this class.
934
- */
935
- class ExternalTokenizer {
936
- /**
937
- Create a tokenizer. The first argument is the function that,
938
- given an input stream, scans for the types of tokens it
939
- recognizes at the stream's position, and calls
940
- [`acceptToken`](#lr.InputStream.acceptToken) when it finds
941
- one.
942
- */
943
- constructor(
944
- /**
945
- @internal
946
- */
947
- token, options = {}) {
948
- this.token = token;
949
- this.contextual = !!options.contextual;
950
- this.fallback = !!options.fallback;
951
- this.extend = !!options.extend;
952
- }
953
- }
954
- // Tokenizer data is stored a big uint16 array containing, for each
955
- // state:
956
- //
957
- // - A group bitmask, indicating what token groups are reachable from
958
- // this state, so that paths that can only lead to tokens not in
959
- // any of the current groups can be cut off early.
960
- //
961
- // - The position of the end of the state's sequence of accepting
962
- // tokens
963
- //
964
- // - The number of outgoing edges for the state
965
- //
966
- // - The accepting tokens, as (token id, group mask) pairs
967
- //
968
- // - The outgoing edges, as (start character, end character, state
969
- // index) triples, with end character being exclusive
970
- //
971
- // This function interprets that data, running through a stream as
972
- // long as new states with the a matching group mask can be reached,
973
- // and updating `input.token` when it matches a token.
974
- function readToken(data, input, stack, group, precTable, precOffset) {
975
- let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
976
- scan: for (;;) {
977
- if ((groupMask & data[state]) == 0)
978
- break;
979
- let accEnd = data[state + 1];
980
- // Check whether this state can lead to a token in the current group
981
- // Accept tokens in this state, possibly overwriting
982
- // lower-precedence / shorter tokens
983
- for (let i = state + 3; i < accEnd; i += 2)
984
- if ((data[i + 1] & groupMask) > 0) {
985
- let term = data[i];
986
- if (dialect.allows(term) &&
987
- (input.token.value == -1 || input.token.value == term ||
988
- overrides(term, input.token.value, precTable, precOffset))) {
989
- input.acceptToken(term);
990
- break;
991
- }
992
- }
993
- let next = input.next, low = 0, high = data[state + 2];
994
- // Special case for EOF
995
- if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */) {
996
- state = data[accEnd + high * 3 - 1];
997
- continue scan;
998
- }
999
- // Do a binary search on the state's edges
1000
- for (; low < high;) {
1001
- let mid = (low + high) >> 1;
1002
- let index = accEnd + mid + (mid << 1);
1003
- let from = data[index], to = data[index + 1] || 0x10000;
1004
- if (next < from)
1005
- high = mid;
1006
- else if (next >= to)
1007
- low = mid + 1;
1008
- else {
1009
- state = data[index + 2];
1010
- input.advance();
1011
- continue scan;
1012
- }
1013
- }
1014
- break;
1015
- }
1016
- }
1017
- function findOffset(data, start, term) {
1018
- for (let i = start, next; (next = data[i]) != 65535 /* Seq.End */; i++)
1019
- if (next == term)
1020
- return i - start;
1021
- return -1;
1022
- }
1023
- function overrides(token, prev, tableData, tableOffset) {
1024
- let iPrev = findOffset(tableData, tableOffset, prev);
1025
- return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
1026
- }
1027
-
1028
- // Environment variable used to control console output
1029
- const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
1030
- let stackIDs = null;
1031
- function cutAt(tree, pos, side) {
1032
- let cursor = tree.cursor(index.IterMode.IncludeAnonymous);
1033
- cursor.moveTo(pos);
1034
- for (;;) {
1035
- if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
1036
- for (;;) {
1037
- if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
1038
- return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Safety.Margin */))
1039
- : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Safety.Margin */));
1040
- if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
1041
- break;
1042
- if (!cursor.parent())
1043
- return side < 0 ? 0 : tree.length;
1044
- }
1045
- }
1046
- }
1047
- class FragmentCursor {
1048
- constructor(fragments, nodeSet) {
1049
- this.fragments = fragments;
1050
- this.nodeSet = nodeSet;
1051
- this.i = 0;
1052
- this.fragment = null;
1053
- this.safeFrom = -1;
1054
- this.safeTo = -1;
1055
- this.trees = [];
1056
- this.start = [];
1057
- this.index = [];
1058
- this.nextFragment();
1059
- }
1060
- nextFragment() {
1061
- let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
1062
- if (fr) {
1063
- this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
1064
- this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
1065
- while (this.trees.length) {
1066
- this.trees.pop();
1067
- this.start.pop();
1068
- this.index.pop();
1069
- }
1070
- this.trees.push(fr.tree);
1071
- this.start.push(-fr.offset);
1072
- this.index.push(0);
1073
- this.nextStart = this.safeFrom;
1074
- }
1075
- else {
1076
- this.nextStart = 1e9;
1077
- }
1078
- }
1079
- // `pos` must be >= any previously given `pos` for this cursor
1080
- nodeAt(pos) {
1081
- if (pos < this.nextStart)
1082
- return null;
1083
- while (this.fragment && this.safeTo <= pos)
1084
- this.nextFragment();
1085
- if (!this.fragment)
1086
- return null;
1087
- for (;;) {
1088
- let last = this.trees.length - 1;
1089
- if (last < 0) { // End of tree
1090
- this.nextFragment();
1091
- return null;
1092
- }
1093
- let top = this.trees[last], index$1 = this.index[last];
1094
- if (index$1 == top.children.length) {
1095
- this.trees.pop();
1096
- this.start.pop();
1097
- this.index.pop();
1098
- continue;
1099
- }
1100
- let next = top.children[index$1];
1101
- let start = this.start[last] + top.positions[index$1];
1102
- if (start > pos) {
1103
- this.nextStart = start;
1104
- return null;
1105
- }
1106
- if (next instanceof index.Tree) {
1107
- if (start == pos) {
1108
- if (start < this.safeFrom)
1109
- return null;
1110
- let end = start + next.length;
1111
- if (end <= this.safeTo) {
1112
- let lookAhead = next.prop(index.NodeProp.lookAhead);
1113
- if (!lookAhead || end + lookAhead < this.fragment.to)
1114
- return next;
1115
- }
1116
- }
1117
- this.index[last]++;
1118
- if (start + next.length >= Math.max(this.safeFrom, pos)) { // Enter this node
1119
- this.trees.push(next);
1120
- this.start.push(start);
1121
- this.index.push(0);
1122
- }
1123
- }
1124
- else {
1125
- this.index[last]++;
1126
- this.nextStart = start + next.length;
1127
- }
1128
- }
1129
- }
1130
- }
1131
- class TokenCache {
1132
- constructor(parser, stream) {
1133
- this.stream = stream;
1134
- this.tokens = [];
1135
- this.mainToken = null;
1136
- this.actions = [];
1137
- this.tokens = parser.tokenizers.map(_ => new CachedToken);
1138
- }
1139
- getActions(stack) {
1140
- let actionIndex = 0;
1141
- let main = null;
1142
- let { parser } = stack.p, { tokenizers } = parser;
1143
- let mask = parser.stateSlot(stack.state, 3 /* ParseState.TokenizerMask */);
1144
- let context = stack.curContext ? stack.curContext.hash : 0;
1145
- let lookAhead = 0;
1146
- for (let i = 0; i < tokenizers.length; i++) {
1147
- if (((1 << i) & mask) == 0)
1148
- continue;
1149
- let tokenizer = tokenizers[i], token = this.tokens[i];
1150
- if (main && !tokenizer.fallback)
1151
- continue;
1152
- if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
1153
- this.updateCachedToken(token, tokenizer, stack);
1154
- token.mask = mask;
1155
- token.context = context;
1156
- }
1157
- if (token.lookAhead > token.end + 25 /* Safety.Margin */)
1158
- lookAhead = Math.max(token.lookAhead, lookAhead);
1159
- if (token.value != 0 /* Term.Err */) {
1160
- let startIndex = actionIndex;
1161
- if (token.extended > -1)
1162
- actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
1163
- actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
1164
- if (!tokenizer.extend) {
1165
- main = token;
1166
- if (actionIndex > startIndex)
1167
- break;
1168
- }
1169
- }
1170
- }
1171
- while (this.actions.length > actionIndex)
1172
- this.actions.pop();
1173
- if (lookAhead)
1174
- stack.setLookAhead(lookAhead);
1175
- if (!main && stack.pos == this.stream.end) {
1176
- main = new CachedToken;
1177
- main.value = stack.p.parser.eofTerm;
1178
- main.start = main.end = stack.pos;
1179
- actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
1180
- }
1181
- this.mainToken = main;
1182
- return this.actions;
1183
- }
1184
- getMainToken(stack) {
1185
- if (this.mainToken)
1186
- return this.mainToken;
1187
- let main = new CachedToken, { pos, p } = stack;
1188
- main.start = pos;
1189
- main.end = Math.min(pos + 1, p.stream.end);
1190
- main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Term.Err */;
1191
- return main;
1192
- }
1193
- updateCachedToken(token, tokenizer, stack) {
1194
- let start = this.stream.clipPos(stack.pos);
1195
- tokenizer.token(this.stream.reset(start, token), stack);
1196
- if (token.value > -1) {
1197
- let { parser } = stack.p;
1198
- for (let i = 0; i < parser.specialized.length; i++)
1199
- if (parser.specialized[i] == token.value) {
1200
- let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);
1201
- if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
1202
- if ((result & 1) == 0 /* Specialize.Specialize */)
1203
- token.value = result >> 1;
1204
- else
1205
- token.extended = result >> 1;
1206
- break;
1207
- }
1208
- }
1209
- }
1210
- else {
1211
- token.value = 0 /* Term.Err */;
1212
- token.end = this.stream.clipPos(start + 1);
1213
- }
1214
- }
1215
- putAction(action, token, end, index) {
1216
- // Don't add duplicate actions
1217
- for (let i = 0; i < index; i += 3)
1218
- if (this.actions[i] == action)
1219
- return index;
1220
- this.actions[index++] = action;
1221
- this.actions[index++] = token;
1222
- this.actions[index++] = end;
1223
- return index;
1224
- }
1225
- addActions(stack, token, end, index) {
1226
- let { state } = stack, { parser } = stack.p, { data } = parser;
1227
- for (let set = 0; set < 2; set++) {
1228
- for (let i = parser.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */);; i += 3) {
1229
- if (data[i] == 65535 /* Seq.End */) {
1230
- if (data[i + 1] == 1 /* Seq.Next */) {
1231
- i = pair(data, i + 2);
1232
- }
1233
- else {
1234
- if (index == 0 && data[i + 1] == 2 /* Seq.Other */)
1235
- index = this.putAction(pair(data, i + 2), token, end, index);
1236
- break;
1237
- }
1238
- }
1239
- if (data[i] == token)
1240
- index = this.putAction(pair(data, i + 1), token, end, index);
1241
- }
1242
- }
1243
- return index;
1244
- }
1245
- }
1246
- class Parse {
1247
- constructor(parser, input, fragments, ranges) {
1248
- this.parser = parser;
1249
- this.input = input;
1250
- this.ranges = ranges;
1251
- this.recovering = 0;
1252
- this.nextStackID = 0x2654; // ♔, ♕, ♖, ♗, ♘, ♙, ♠, ♡, ♢, ♣, ♤, ♥, ♦, ♧
1253
- this.minStackPos = 0;
1254
- this.reused = [];
1255
- this.stoppedAt = null;
1256
- this.lastBigReductionStart = -1;
1257
- this.lastBigReductionSize = 0;
1258
- this.bigReductionCount = 0;
1259
- this.stream = new InputStream(input, ranges);
1260
- this.tokens = new TokenCache(parser, this.stream);
1261
- this.topTerm = parser.top[1];
1262
- let { from } = ranges[0];
1263
- this.stacks = [Stack.start(this, parser.top[0], from)];
1264
- this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4
1265
- ? new FragmentCursor(fragments, parser.nodeSet) : null;
1266
- }
1267
- get parsedPos() {
1268
- return this.minStackPos;
1269
- }
1270
- // Move the parser forward. This will process all parse stacks at
1271
- // `this.pos` and try to advance them to a further position. If no
1272
- // stack for such a position is found, it'll start error-recovery.
1273
- //
1274
- // When the parse is finished, this will return a syntax tree. When
1275
- // not, it returns `null`.
1276
- advance() {
1277
- let stacks = this.stacks, pos = this.minStackPos;
1278
- // This will hold stacks beyond `pos`.
1279
- let newStacks = this.stacks = [];
1280
- let stopped, stoppedTokens;
1281
- // If a large amount of reductions happened with the same start
1282
- // position, force the stack out of that production in order to
1283
- // avoid creating a tree too deep to recurse through.
1284
- // (This is an ugly kludge, because unfortunately there is no
1285
- // straightforward, cheap way to check for this happening, due to
1286
- // the history of reductions only being available in an
1287
- // expensive-to-access format in the stack buffers.)
1288
- if (this.bigReductionCount > 300 /* Rec.MaxLeftAssociativeReductionCount */ && stacks.length == 1) {
1289
- let [s] = stacks;
1290
- while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) { }
1291
- this.bigReductionCount = this.lastBigReductionSize = 0;
1292
- }
1293
- // Keep advancing any stacks at `pos` until they either move
1294
- // forward or can't be advanced. Gather stacks that can't be
1295
- // advanced further in `stopped`.
1296
- for (let i = 0; i < stacks.length; i++) {
1297
- let stack = stacks[i];
1298
- for (;;) {
1299
- this.tokens.mainToken = null;
1300
- if (stack.pos > pos) {
1301
- newStacks.push(stack);
1302
- }
1303
- else if (this.advanceStack(stack, newStacks, stacks)) {
1304
- continue;
1305
- }
1306
- else {
1307
- if (!stopped) {
1308
- stopped = [];
1309
- stoppedTokens = [];
1310
- }
1311
- stopped.push(stack);
1312
- let tok = this.tokens.getMainToken(stack);
1313
- stoppedTokens.push(tok.value, tok.end);
1314
- }
1315
- break;
1316
- }
1317
- }
1318
- if (!newStacks.length) {
1319
- let finished = stopped && findFinished(stopped);
1320
- if (finished) {
1321
- if (verbose)
1322
- console.log("Finish with " + this.stackID(finished));
1323
- return this.stackToTree(finished);
1324
- }
1325
- if (this.parser.strict) {
1326
- if (verbose && stopped)
1327
- console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
1328
- throw new SyntaxError("No parse at " + pos);
1329
- }
1330
- if (!this.recovering)
1331
- this.recovering = 5 /* Rec.Distance */;
1332
- }
1333
- if (this.recovering && stopped) {
1334
- let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0]
1335
- : this.runRecovery(stopped, stoppedTokens, newStacks);
1336
- if (finished) {
1337
- if (verbose)
1338
- console.log("Force-finish " + this.stackID(finished));
1339
- return this.stackToTree(finished.forceAll());
1340
- }
1341
- }
1342
- if (this.recovering) {
1343
- let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* Rec.MaxRemainingPerStep */;
1344
- if (newStacks.length > maxRemaining) {
1345
- newStacks.sort((a, b) => b.score - a.score);
1346
- while (newStacks.length > maxRemaining)
1347
- newStacks.pop();
1348
- }
1349
- if (newStacks.some(s => s.reducePos > pos))
1350
- this.recovering--;
1351
- }
1352
- else if (newStacks.length > 1) {
1353
- // Prune stacks that are in the same state, or that have been
1354
- // running without splitting for a while, to avoid getting stuck
1355
- // with multiple successful stacks running endlessly on.
1356
- outer: for (let i = 0; i < newStacks.length - 1; i++) {
1357
- let stack = newStacks[i];
1358
- for (let j = i + 1; j < newStacks.length; j++) {
1359
- let other = newStacks[j];
1360
- if (stack.sameState(other) ||
1361
- stack.buffer.length > 500 /* Rec.MinBufferLengthPrune */ && other.buffer.length > 500 /* Rec.MinBufferLengthPrune */) {
1362
- if (((stack.score - other.score) || (stack.buffer.length - other.buffer.length)) > 0) {
1363
- newStacks.splice(j--, 1);
1364
- }
1365
- else {
1366
- newStacks.splice(i--, 1);
1367
- continue outer;
1368
- }
1369
- }
1370
- }
1371
- }
1372
- if (newStacks.length > 12 /* Rec.MaxStackCount */)
1373
- newStacks.splice(12 /* Rec.MaxStackCount */, newStacks.length - 12 /* Rec.MaxStackCount */);
1374
- }
1375
- this.minStackPos = newStacks[0].pos;
1376
- for (let i = 1; i < newStacks.length; i++)
1377
- if (newStacks[i].pos < this.minStackPos)
1378
- this.minStackPos = newStacks[i].pos;
1379
- return null;
1380
- }
1381
- stopAt(pos) {
1382
- if (this.stoppedAt != null && this.stoppedAt < pos)
1383
- throw new RangeError("Can't move stoppedAt forward");
1384
- this.stoppedAt = pos;
1385
- }
1386
- // Returns an updated version of the given stack, or null if the
1387
- // stack can't advance normally. When `split` and `stacks` are
1388
- // given, stacks split off by ambiguous operations will be pushed to
1389
- // `split`, or added to `stacks` if they move `pos` forward.
1390
- advanceStack(stack, stacks, split) {
1391
- let start = stack.pos, { parser } = this;
1392
- let base = verbose ? this.stackID(stack) + " -> " : "";
1393
- if (this.stoppedAt != null && start > this.stoppedAt)
1394
- return stack.forceReduce() ? stack : null;
1395
- if (this.fragments) {
1396
- let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
1397
- for (let cached = this.fragments.nodeAt(start); cached;) {
1398
- let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;
1399
- if (match > -1 && cached.length && (!strictCx || (cached.prop(index.NodeProp.contextHash) || 0) == cxHash)) {
1400
- stack.useNode(cached, match);
1401
- if (verbose)
1402
- console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
1403
- return true;
1404
- }
1405
- if (!(cached instanceof index.Tree) || cached.children.length == 0 || cached.positions[0] > 0)
1406
- break;
1407
- let inner = cached.children[0];
1408
- if (inner instanceof index.Tree && cached.positions[0] == 0)
1409
- cached = inner;
1410
- else
1411
- break;
1412
- }
1413
- }
1414
- let defaultReduce = parser.stateSlot(stack.state, 4 /* ParseState.DefaultReduce */);
1415
- if (defaultReduce > 0) {
1416
- stack.reduce(defaultReduce);
1417
- if (verbose)
1418
- console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* Action.ValueMask */)})`);
1419
- return true;
1420
- }
1421
- if (stack.stack.length >= 8400 /* Rec.CutDepth */) {
1422
- while (stack.stack.length > 6000 /* Rec.CutTo */ && stack.forceReduce()) { }
1423
- }
1424
- let actions = this.tokens.getActions(stack);
1425
- for (let i = 0; i < actions.length;) {
1426
- let action = actions[i++], term = actions[i++], end = actions[i++];
1427
- let last = i == actions.length || !split;
1428
- let localStack = last ? stack : stack.split();
1429
- let main = this.tokens.mainToken;
1430
- localStack.apply(action, term, main ? main.start : localStack.pos, end);
1431
- if (verbose)
1432
- console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* Action.ReduceFlag */) == 0 ? "shift"
1433
- : `reduce of ${parser.getName(action & 65535 /* Action.ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
1434
- if (last)
1435
- return true;
1436
- else if (localStack.pos > start)
1437
- stacks.push(localStack);
1438
- else
1439
- split.push(localStack);
1440
- }
1441
- return false;
1442
- }
1443
- // Advance a given stack forward as far as it will go. Returns the
1444
- // (possibly updated) stack if it got stuck, or null if it moved
1445
- // forward and was given to `pushStackDedup`.
1446
- advanceFully(stack, newStacks) {
1447
- let pos = stack.pos;
1448
- for (;;) {
1449
- if (!this.advanceStack(stack, null, null))
1450
- return false;
1451
- if (stack.pos > pos) {
1452
- pushStackDedup(stack, newStacks);
1453
- return true;
1454
- }
1455
- }
1456
- }
1457
- runRecovery(stacks, tokens, newStacks) {
1458
- let finished = null, restarted = false;
1459
- for (let i = 0; i < stacks.length; i++) {
1460
- let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
1461
- let base = verbose ? this.stackID(stack) + " -> " : "";
1462
- if (stack.deadEnd) {
1463
- if (restarted)
1464
- continue;
1465
- restarted = true;
1466
- stack.restart();
1467
- if (verbose)
1468
- console.log(base + this.stackID(stack) + " (restarted)");
1469
- let done = this.advanceFully(stack, newStacks);
1470
- if (done)
1471
- continue;
1472
- }
1473
- let force = stack.split(), forceBase = base;
1474
- for (let j = 0; force.forceReduce() && j < 10 /* Rec.ForceReduceLimit */; j++) {
1475
- if (verbose)
1476
- console.log(forceBase + this.stackID(force) + " (via force-reduce)");
1477
- let done = this.advanceFully(force, newStacks);
1478
- if (done)
1479
- break;
1480
- if (verbose)
1481
- forceBase = this.stackID(force) + " -> ";
1482
- }
1483
- for (let insert of stack.recoverByInsert(token)) {
1484
- if (verbose)
1485
- console.log(base + this.stackID(insert) + " (via recover-insert)");
1486
- this.advanceFully(insert, newStacks);
1487
- }
1488
- if (this.stream.end > stack.pos) {
1489
- if (tokenEnd == stack.pos) {
1490
- tokenEnd++;
1491
- token = 0 /* Term.Err */;
1492
- }
1493
- stack.recoverByDelete(token, tokenEnd);
1494
- if (verbose)
1495
- console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
1496
- pushStackDedup(stack, newStacks);
1497
- }
1498
- else if (!finished || finished.score < stack.score) {
1499
- finished = stack;
1500
- }
1501
- }
1502
- return finished;
1503
- }
1504
- // Convert the stack's buffer to a syntax tree.
1505
- stackToTree(stack) {
1506
- stack.close();
1507
- return index.Tree.build({ buffer: StackBufferCursor.create(stack),
1508
- nodeSet: this.parser.nodeSet,
1509
- topID: this.topTerm,
1510
- maxBufferLength: this.parser.bufferLength,
1511
- reused: this.reused,
1512
- start: this.ranges[0].from,
1513
- length: stack.pos - this.ranges[0].from,
1514
- minRepeatType: this.parser.minRepeatTerm });
1515
- }
1516
- stackID(stack) {
1517
- let id = (stackIDs || (stackIDs = new WeakMap)).get(stack);
1518
- if (!id)
1519
- stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
1520
- return id + stack;
1521
- }
1522
- }
1523
- function pushStackDedup(stack, newStacks) {
1524
- for (let i = 0; i < newStacks.length; i++) {
1525
- let other = newStacks[i];
1526
- if (other.pos == stack.pos && other.sameState(stack)) {
1527
- if (newStacks[i].score < stack.score)
1528
- newStacks[i] = stack;
1529
- return;
1530
- }
1531
- }
1532
- newStacks.push(stack);
1533
- }
1534
- class Dialect {
1535
- constructor(source, flags, disabled) {
1536
- this.source = source;
1537
- this.flags = flags;
1538
- this.disabled = disabled;
1539
- }
1540
- allows(term) { return !this.disabled || this.disabled[term] == 0; }
1541
- }
1542
- const id = x => x;
1543
- /**
1544
- Context trackers are used to track stateful context (such as
1545
- indentation in the Python grammar, or parent elements in the XML
1546
- grammar) needed by external tokenizers. You declare them in a
1547
- grammar file as `@context exportName from "module"`.
1548
-
1549
- Context values should be immutable, and can be updated (replaced)
1550
- on shift or reduce actions.
1551
-
1552
- The export used in a `@context` declaration should be of this
1553
- type.
1554
- */
1555
- class ContextTracker {
1556
- /**
1557
- Define a context tracker.
1558
- */
1559
- constructor(spec) {
1560
- this.start = spec.start;
1561
- this.shift = spec.shift || id;
1562
- this.reduce = spec.reduce || id;
1563
- this.reuse = spec.reuse || id;
1564
- this.hash = spec.hash || (() => 0);
1565
- this.strict = spec.strict !== false;
1566
- }
1567
- }
1568
- /**
1569
- Holds the parse tables for a given grammar, as generated by
1570
- `lezer-generator`, and provides [methods](#common.Parser) to parse
1571
- content with.
1572
- */
1573
- class LRParser extends index.Parser {
1574
- /**
1575
- @internal
1576
- */
1577
- constructor(spec) {
1578
- super();
1579
- /**
1580
- @internal
1581
- */
1582
- this.wrappers = [];
1583
- if (spec.version != 14 /* File.Version */)
1584
- throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* File.Version */})`);
1585
- let nodeNames = spec.nodeNames.split(" ");
1586
- this.minRepeatTerm = nodeNames.length;
1587
- for (let i = 0; i < spec.repeatNodeCount; i++)
1588
- nodeNames.push("");
1589
- let topTerms = Object.keys(spec.topRules).map(r => spec.topRules[r][1]);
1590
- let nodeProps = [];
1591
- for (let i = 0; i < nodeNames.length; i++)
1592
- nodeProps.push([]);
1593
- function setProp(nodeID, prop, value) {
1594
- nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
1595
- }
1596
- if (spec.nodeProps)
1597
- for (let propSpec of spec.nodeProps) {
1598
- let prop = propSpec[0];
1599
- if (typeof prop == "string")
1600
- prop = index.NodeProp[prop];
1601
- for (let i = 1; i < propSpec.length;) {
1602
- let next = propSpec[i++];
1603
- if (next >= 0) {
1604
- setProp(next, prop, propSpec[i++]);
1605
- }
1606
- else {
1607
- let value = propSpec[i + -next];
1608
- for (let j = -next; j > 0; j--)
1609
- setProp(propSpec[i++], prop, value);
1610
- i++;
1611
- }
1612
- }
1613
- }
1614
- this.nodeSet = new index.NodeSet(nodeNames.map((name, i) => index.NodeType.define({
1615
- name: i >= this.minRepeatTerm ? undefined : name,
1616
- id: i,
1617
- props: nodeProps[i],
1618
- top: topTerms.indexOf(i) > -1,
1619
- error: i == 0,
1620
- skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
1621
- })));
1622
- if (spec.propSources)
1623
- this.nodeSet = this.nodeSet.extend(...spec.propSources);
1624
- this.strict = false;
1625
- this.bufferLength = index.DefaultBufferLength;
1626
- let tokenArray = decodeArray(spec.tokenData);
1627
- this.context = spec.context;
1628
- this.specializerSpecs = spec.specialized || [];
1629
- this.specialized = new Uint16Array(this.specializerSpecs.length);
1630
- for (let i = 0; i < this.specializerSpecs.length; i++)
1631
- this.specialized[i] = this.specializerSpecs[i].term;
1632
- this.specializers = this.specializerSpecs.map(getSpecializer);
1633
- this.states = decodeArray(spec.states, Uint32Array);
1634
- this.data = decodeArray(spec.stateData);
1635
- this.goto = decodeArray(spec.goto);
1636
- this.maxTerm = spec.maxTerm;
1637
- this.tokenizers = spec.tokenizers.map(value => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
1638
- this.topRules = spec.topRules;
1639
- this.dialects = spec.dialects || {};
1640
- this.dynamicPrecedences = spec.dynamicPrecedences || null;
1641
- this.tokenPrecTable = spec.tokenPrec;
1642
- this.termNames = spec.termNames || null;
1643
- this.maxNode = this.nodeSet.types.length - 1;
1644
- this.dialect = this.parseDialect();
1645
- this.top = this.topRules[Object.keys(this.topRules)[0]];
1646
- }
1647
- createParse(input, fragments, ranges) {
1648
- let parse = new Parse(this, input, fragments, ranges);
1649
- for (let w of this.wrappers)
1650
- parse = w(parse, input, fragments, ranges);
1651
- return parse;
1652
- }
1653
- /**
1654
- Get a goto table entry @internal
1655
- */
1656
- getGoto(state, term, loose = false) {
1657
- let table = this.goto;
1658
- if (term >= table[0])
1659
- return -1;
1660
- for (let pos = table[term + 1];;) {
1661
- let groupTag = table[pos++], last = groupTag & 1;
1662
- let target = table[pos++];
1663
- if (last && loose)
1664
- return target;
1665
- for (let end = pos + (groupTag >> 1); pos < end; pos++)
1666
- if (table[pos] == state)
1667
- return target;
1668
- if (last)
1669
- return -1;
1670
- }
1671
- }
1672
- /**
1673
- Check if this state has an action for a given terminal @internal
1674
- */
1675
- hasAction(state, terminal) {
1676
- let data = this.data;
1677
- for (let set = 0; set < 2; set++) {
1678
- for (let i = this.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */), next;; i += 3) {
1679
- if ((next = data[i]) == 65535 /* Seq.End */) {
1680
- if (data[i + 1] == 1 /* Seq.Next */)
1681
- next = data[i = pair(data, i + 2)];
1682
- else if (data[i + 1] == 2 /* Seq.Other */)
1683
- return pair(data, i + 2);
1684
- else
1685
- break;
1686
- }
1687
- if (next == terminal || next == 0 /* Term.Err */)
1688
- return pair(data, i + 1);
1689
- }
1690
- }
1691
- return 0;
1692
- }
1693
- /**
1694
- @internal
1695
- */
1696
- stateSlot(state, slot) {
1697
- return this.states[(state * 6 /* ParseState.Size */) + slot];
1698
- }
1699
- /**
1700
- @internal
1701
- */
1702
- stateFlag(state, flag) {
1703
- return (this.stateSlot(state, 0 /* ParseState.Flags */) & flag) > 0;
1704
- }
1705
- /**
1706
- @internal
1707
- */
1708
- validAction(state, action) {
1709
- return !!this.allActions(state, a => a == action ? true : null);
1710
- }
1711
- /**
1712
- @internal
1713
- */
1714
- allActions(state, action) {
1715
- let deflt = this.stateSlot(state, 4 /* ParseState.DefaultReduce */);
1716
- let result = deflt ? action(deflt) : undefined;
1717
- for (let i = this.stateSlot(state, 1 /* ParseState.Actions */); result == null; i += 3) {
1718
- if (this.data[i] == 65535 /* Seq.End */) {
1719
- if (this.data[i + 1] == 1 /* Seq.Next */)
1720
- i = pair(this.data, i + 2);
1721
- else
1722
- break;
1723
- }
1724
- result = action(pair(this.data, i + 1));
1725
- }
1726
- return result;
1727
- }
1728
- /**
1729
- Get the states that can follow this one through shift actions or
1730
- goto jumps. @internal
1731
- */
1732
- nextStates(state) {
1733
- let result = [];
1734
- for (let i = this.stateSlot(state, 1 /* ParseState.Actions */);; i += 3) {
1735
- if (this.data[i] == 65535 /* Seq.End */) {
1736
- if (this.data[i + 1] == 1 /* Seq.Next */)
1737
- i = pair(this.data, i + 2);
1738
- else
1739
- break;
1740
- }
1741
- if ((this.data[i + 2] & (65536 /* Action.ReduceFlag */ >> 16)) == 0) {
1742
- let value = this.data[i + 1];
1743
- if (!result.some((v, i) => (i & 1) && v == value))
1744
- result.push(this.data[i], value);
1745
- }
1746
- }
1747
- return result;
1748
- }
1749
- /**
1750
- Configure the parser. Returns a new parser instance that has the
1751
- given settings modified. Settings not provided in `config` are
1752
- kept from the original parser.
1753
- */
1754
- configure(config) {
1755
- // Hideous reflection-based kludge to make it easy to create a
1756
- // slightly modified copy of a parser.
1757
- let copy = Object.assign(Object.create(LRParser.prototype), this);
1758
- if (config.props)
1759
- copy.nodeSet = this.nodeSet.extend(...config.props);
1760
- if (config.top) {
1761
- let info = this.topRules[config.top];
1762
- if (!info)
1763
- throw new RangeError(`Invalid top rule name ${config.top}`);
1764
- copy.top = info;
1765
- }
1766
- if (config.tokenizers)
1767
- copy.tokenizers = this.tokenizers.map(t => {
1768
- let found = config.tokenizers.find(r => r.from == t);
1769
- return found ? found.to : t;
1770
- });
1771
- if (config.specializers) {
1772
- copy.specializers = this.specializers.slice();
1773
- copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
1774
- let found = config.specializers.find(r => r.from == s.external);
1775
- if (!found)
1776
- return s;
1777
- let spec = Object.assign(Object.assign({}, s), { external: found.to });
1778
- copy.specializers[i] = getSpecializer(spec);
1779
- return spec;
1780
- });
1781
- }
1782
- if (config.contextTracker)
1783
- copy.context = config.contextTracker;
1784
- if (config.dialect)
1785
- copy.dialect = this.parseDialect(config.dialect);
1786
- if (config.strict != null)
1787
- copy.strict = config.strict;
1788
- if (config.wrap)
1789
- copy.wrappers = copy.wrappers.concat(config.wrap);
1790
- if (config.bufferLength != null)
1791
- copy.bufferLength = config.bufferLength;
1792
- return copy;
1793
- }
1794
- /**
1795
- Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
1796
- are registered for this parser.
1797
- */
1798
- hasWrappers() {
1799
- return this.wrappers.length > 0;
1800
- }
1801
- /**
1802
- Returns the name associated with a given term. This will only
1803
- work for all terms when the parser was generated with the
1804
- `--names` option. By default, only the names of tagged terms are
1805
- stored.
1806
- */
1807
- getName(term) {
1808
- return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
1809
- }
1810
- /**
1811
- The eof term id is always allocated directly after the node
1812
- types. @internal
1813
- */
1814
- get eofTerm() { return this.maxNode + 1; }
1815
- /**
1816
- The type of top node produced by the parser.
1817
- */
1818
- get topNode() { return this.nodeSet.types[this.top[1]]; }
1819
- /**
1820
- @internal
1821
- */
1822
- dynamicPrecedence(term) {
1823
- let prec = this.dynamicPrecedences;
1824
- return prec == null ? 0 : prec[term] || 0;
1825
- }
1826
- /**
1827
- @internal
1828
- */
1829
- parseDialect(dialect) {
1830
- let values = Object.keys(this.dialects), flags = values.map(() => false);
1831
- if (dialect)
1832
- for (let part of dialect.split(" ")) {
1833
- let id = values.indexOf(part);
1834
- if (id >= 0)
1835
- flags[id] = true;
1836
- }
1837
- let disabled = null;
1838
- for (let i = 0; i < values.length; i++)
1839
- if (!flags[i]) {
1840
- for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* Seq.End */;)
1841
- (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
1842
- }
1843
- return new Dialect(dialect, flags, disabled);
1844
- }
1845
- /**
1846
- Used by the output of the parser generator. Not available to
1847
- user code. @hide
1848
- */
1849
- static deserialize(spec) {
1850
- return new LRParser(spec);
1851
- }
1852
- }
1853
- function pair(data, off) { return data[off] | (data[off + 1] << 16); }
1854
- function findFinished(stacks) {
1855
- let best = null;
1856
- for (let stack of stacks) {
1857
- let stopped = stack.p.stoppedAt;
1858
- if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) &&
1859
- stack.p.parser.stateFlag(stack.state, 2 /* StateFlag.Accepting */) &&
1860
- (!best || best.score < stack.score))
1861
- best = stack;
1862
- }
1863
- return best;
1864
- }
1865
- function getSpecializer(spec) {
1866
- if (spec.external) {
1867
- let mask = spec.extend ? 1 /* Specialize.Extend */ : 0 /* Specialize.Specialize */;
1868
- return (value, stack) => (spec.external(value, stack) << 1) | mask;
1869
- }
1870
- return spec.get;
1871
- }
1872
-
1873
- exports.ContextTracker = ContextTracker;
1874
- exports.ExternalTokenizer = ExternalTokenizer;
1875
- exports.LRParser = LRParser;
1876
- exports.LocalTokenGroup = LocalTokenGroup;
1877
- //# sourceMappingURL=index-zXSAHvAj.js.map