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