@axdspub/axiom-ui-forms 0.2.8 → 0.2.9

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