functionalscript 0.37.0 → 0.38.0

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 (500) hide show
  1. package/README.md +1 -1
  2. package/{fs → fjs}/asn.1/proof.f.js +32 -94
  3. package/fjs/asserts/module.f.d.ts +36 -0
  4. package/fjs/asserts/module.f.js +39 -0
  5. package/fjs/asserts/proof.f.d.ts +11 -0
  6. package/fjs/asserts/proof.f.js +18 -0
  7. package/{fs → fjs}/base_n/proof.f.js +12 -36
  8. package/{fs → fjs}/basen/base64/proof.f.d.ts +1 -0
  9. package/{fs → fjs}/basen/base64/proof.f.js +15 -1
  10. package/{fs → fjs}/basen/cbase32/proof.f.js +15 -42
  11. package/fjs/bnf/data/module.f.d.ts +52 -0
  12. package/{fs → fjs}/bnf/data/module.f.js +53 -3
  13. package/{fs → fjs}/bnf/data/proof.f.d.ts +1 -0
  14. package/{fs → fjs}/bnf/data/proof.f.js +54 -19
  15. package/{fs → fjs}/bnf/descent/module.f.d.ts +4 -14
  16. package/fjs/bnf/descent/module.f.js +124 -0
  17. package/{fs → fjs}/bnf/descent/proof.f.d.ts +1 -0
  18. package/{fs → fjs}/bnf/descent/proof.f.js +55 -24
  19. package/{fs → fjs}/bnf/ll1/module.f.d.ts +4 -4
  20. package/{fs → fjs}/bnf/ll1/module.f.js +7 -5
  21. package/{fs → fjs}/bnf/ll1/proof.f.d.ts +1 -0
  22. package/{fs → fjs}/bnf/ll1/proof.f.js +27 -10
  23. package/{fs → fjs}/bnf/module.f.d.ts +19 -5
  24. package/{fs → fjs}/bnf/module.f.js +10 -11
  25. package/fjs/bnf/proof.f.js +69 -0
  26. package/{fs → fjs}/bnf/testlib.f.js +2 -2
  27. package/{fs → fjs}/cas/cli/proof.f.d.ts +4 -1
  28. package/{fs → fjs}/cas/cli/proof.f.js +29 -66
  29. package/fjs/cas/evo/mcp/module.f.d.ts +19 -0
  30. package/fjs/cas/evo/mcp/module.f.js +56 -0
  31. package/fjs/cas/evo/mcp/proof.f.d.ts +9 -0
  32. package/fjs/cas/evo/mcp/proof.f.js +95 -0
  33. package/fjs/cas/evo/module.f.d.ts +138 -0
  34. package/fjs/cas/evo/module.f.js +309 -0
  35. package/fjs/cas/evo/proof.f.d.ts +32 -0
  36. package/fjs/cas/evo/proof.f.js +453 -0
  37. package/fjs/cas/mcp/module.f.d.ts +49 -0
  38. package/{fs → fjs}/cas/mcp/module.f.js +54 -76
  39. package/{fs → fjs}/cas/mcp/proof.f.d.ts +4 -1
  40. package/{fs → fjs}/cas/mcp/proof.f.js +41 -13
  41. package/{fs → fjs}/cas/module.f.d.ts +10 -0
  42. package/{fs → fjs}/cas/module.f.js +27 -1
  43. package/{fs → fjs}/cas/proof.f.d.ts +4 -0
  44. package/{fs → fjs}/cas/proof.f.js +77 -86
  45. package/{fs → fjs}/ci/config/module.f.d.ts +5 -5
  46. package/{fs → fjs}/ci/config/module.f.js +5 -5
  47. package/{fs → fjs}/ci/proof.f.js +14 -9
  48. package/{fs → fjs}/ci/rust/module.f.js +9 -1
  49. package/{fs → fjs}/cli/proof.f.js +22 -63
  50. package/{fs → fjs}/common/monoid/proof.f.js +4 -9
  51. package/{fs → fjs}/crypto/hmac/proof.f.js +4 -12
  52. package/fjs/crypto/pow/proof.f.js +111 -0
  53. package/{fs → fjs}/crypto/secp/proof.f.js +12 -33
  54. package/{fs → fjs}/crypto/sha2/proof.f.js +18 -49
  55. package/{fs → fjs}/crypto/sign/module.f.d.ts +0 -5
  56. package/{fs → fjs}/crypto/sign/module.f.js +7 -4
  57. package/{fs → fjs}/crypto/sign/proof.f.js +36 -105
  58. package/{fs → fjs}/crypto/vdf/proof.f.js +22 -63
  59. package/{fs → fjs}/dev/package_json/proof.f.js +7 -7
  60. package/{fs → fjs}/dev/proof.f.js +2 -4
  61. package/{fs → fjs}/djs/ast/proof.f.js +4 -12
  62. package/{fs → fjs}/djs/parser/module.f.d.ts +5 -0
  63. package/{fs → fjs}/djs/parser/module.f.js +20 -0
  64. package/{fs → fjs}/djs/parser/proof.f.js +138 -400
  65. package/{fs → fjs}/djs/proof.f.js +13 -36
  66. package/{fs → fjs}/djs/serializer/proof.f.js +14 -39
  67. package/fjs/djs/tokenizer/module.f.d.ts +24 -0
  68. package/fjs/djs/tokenizer/module.f.js +472 -0
  69. package/{fs/djs/tokenizer-new → fjs/djs/tokenizer}/proof.f.d.ts +4 -3
  70. package/{fs/djs/tokenizer-new → fjs/djs/tokenizer}/proof.f.js +446 -445
  71. package/{fs → fjs}/djs/transpiler/proof.f.d.ts +3 -0
  72. package/{fs → fjs}/djs/transpiler/proof.f.js +29 -30
  73. package/{fs → fjs}/effects/memory/proof.f.js +8 -21
  74. package/{fs → fjs}/effects/node/memory/proof.js +5 -12
  75. package/{fs → fjs}/effects/node/module.d.ts +1 -1
  76. package/{fs → fjs}/effects/node/module.f.d.ts +1 -1
  77. package/{fs → fjs}/effects/node/module.js +3 -3
  78. package/{fs → fjs}/effects/node/proof.f.d.ts +1 -0
  79. package/{fs → fjs}/effects/node/proof.f.js +106 -292
  80. package/{fs → fjs}/effects/node/virtual/proof.f.d.ts +1 -0
  81. package/{fs → fjs}/effects/node/virtual/proof.f.js +36 -29
  82. package/{fs → fjs}/effects/proof.f.js +16 -45
  83. package/{fs → fjs}/emergent_testing/proof.f.js +7 -7
  84. package/{fs → fjs}/fsc/proof.f.js +12 -34
  85. package/{fs → fjs}/fsm/proof.f.js +5 -12
  86. package/{fs → fjs}/mcp/module.f.d.ts +7 -0
  87. package/{fs → fjs}/mcp/module.f.js +9 -2
  88. package/{fs → fjs}/mcp/proof.f.js +12 -12
  89. package/{fs → fjs}/mcp/stdio/module.f.d.ts +2 -2
  90. package/{fs → fjs}/mcp/stdio/module.f.js +2 -2
  91. package/{fs → fjs}/media/html/proof.f.js +12 -33
  92. package/{fs → fjs}/media/json/parser/module.f.d.ts +5 -0
  93. package/{fs → fjs}/media/json/parser/module.f.js +14 -0
  94. package/{fs → fjs}/media/json/parser/proof.f.js +39 -114
  95. package/{fs → fjs}/media/json/rpc/module.f.js +1 -1
  96. package/{fs → fjs}/media/json/schema/module.f.d.ts +2 -2
  97. package/{fs → fjs}/media/json/schema/module.f.js +23 -39
  98. package/{fs → fjs}/media/json/schema/proof.f.js +3 -6
  99. package/{fs → fjs}/media/json/serializer/proof.f.js +10 -27
  100. package/{fs → fjs}/media/module.f.d.ts +6 -6
  101. package/{fs → fjs}/media/module.f.js +3 -4
  102. package/{fs → fjs}/media/proof.f.js +5 -4
  103. package/{fs → fjs}/media/revision/module.f.d.ts +31 -4
  104. package/{fs → fjs}/media/revision/module.f.js +35 -23
  105. package/{fs → fjs}/media/revision/proof.f.d.ts +10 -8
  106. package/fjs/media/revision/proof.f.js +140 -0
  107. package/{fs → fjs}/media/type/proof.f.js +2 -6
  108. package/{fs → fjs}/module.f.js +1 -1
  109. package/{fs → fjs}/path/proof.f.js +27 -78
  110. package/{fs → fjs}/proof.f.js +2 -0
  111. package/{fs → fjs}/sul/id/proof.f.js +7 -21
  112. package/{fs → fjs}/sul/level/hash/proof.f.js +5 -5
  113. package/{fs → fjs}/sul/level/literal/proof.f.js +12 -26
  114. package/fjs/text/ascii/proof.f.d.ts +6 -0
  115. package/{fs → fjs}/text/ascii/proof.f.js +4 -14
  116. package/{fs → fjs}/text/code_point/module.f.js +10 -10
  117. package/{fs → fjs}/text/proof.f.js +4 -9
  118. package/{fs → fjs}/text/sgr/proof.f.js +6 -15
  119. package/{fs → fjs}/text/utf16/module.f.js +1 -1
  120. package/{fs → fjs}/text/utf16/proof.f.js +23 -66
  121. package/{fs → fjs}/text/utf8/proof.f.js +56 -125
  122. package/{fs → fjs}/types/array/proof.f.js +18 -52
  123. package/fjs/types/bigfloat/proof.f.js +217 -0
  124. package/{fs → fjs}/types/bigint/proof.f.js +49 -145
  125. package/{fs → fjs}/types/bit_vec/proof.f.js +72 -214
  126. package/{fs → fjs}/types/btree/find/proof.f.js +23 -66
  127. package/{fs → fjs}/types/btree/proof.f.js +5 -12
  128. package/{fs → fjs}/types/btree/remove/proof.f.d.ts +2 -0
  129. package/{fs → fjs}/types/btree/remove/proof.f.js +83 -230
  130. package/{fs → fjs}/types/btree/set/module.f.js +5 -2
  131. package/{fs → fjs}/types/btree/set/proof.f.js +35 -24
  132. package/{fs → fjs}/types/byte_set/proof.f.js +22 -63
  133. package/{fs → fjs}/types/function/compare/proof.f.js +13 -36
  134. package/{fs → fjs}/types/function/operator/proof.f.js +17 -48
  135. package/{fs → fjs}/types/function/proof.f.js +2 -3
  136. package/{fs → fjs}/types/list/proof.f.js +55 -163
  137. package/{fs → fjs}/types/map/proof.f.js +4 -12
  138. package/{fs → fjs}/types/nibble_set/proof.f.js +16 -45
  139. package/{fs → fjs}/types/nominal/proof.f.js +5 -10
  140. package/fjs/types/nullable/proof.f.js +29 -0
  141. package/{fs → fjs}/types/number/proof.f.js +9 -24
  142. package/{fs → fjs}/types/object/proof.f.js +3 -6
  143. package/{fs → fjs}/types/patricia_trie/proof.f.js +21 -21
  144. package/{fs → fjs}/types/prime_field/module.f.js +2 -7
  145. package/{fs → fjs}/types/range/module.f.d.ts +1 -1
  146. package/fjs/types/range/module.f.js +2 -0
  147. package/fjs/types/range/proof.f.js +9 -0
  148. package/{fs → fjs}/types/range_map/proof.f.js +28 -81
  149. package/{fs → fjs}/types/result/proof.f.d.ts +3 -2
  150. package/fjs/types/result/proof.f.js +31 -0
  151. package/{fs → fjs}/types/rtti/common/module.f.d.ts +36 -1
  152. package/{fs → fjs}/types/rtti/common/module.f.js +44 -0
  153. package/fjs/types/rtti/common/proof.f.d.ts +8 -0
  154. package/fjs/types/rtti/common/proof.f.js +51 -0
  155. package/{fs → fjs}/types/rtti/parse/module.f.js +13 -22
  156. package/{fs → fjs}/types/rtti/parse/proof.f.js +7 -18
  157. package/{fs → fjs}/types/rtti/ts/module.f.d.ts +10 -4
  158. package/{fs → fjs}/types/rtti/validate/module.f.js +8 -29
  159. package/{fs → fjs}/types/rtti/validate/proof.f.js +4 -9
  160. package/{fs → fjs}/types/sorted_list/proof.f.js +8 -21
  161. package/{fs → fjs}/types/sorted_set/proof.f.js +14 -39
  162. package/fjs/types/string/proof.f.js +77 -0
  163. package/fjs/types/string_set/proof.f.js +43 -0
  164. package/{fs → fjs}/types/ts/proof.f.js +15 -42
  165. package/{fs → fjs}/types/uint8array/module.f.js +7 -7
  166. package/{fs → fjs}/types/uint8array/proof.f.d.ts +4 -1
  167. package/{fs → fjs}/types/uint8array/proof.f.js +7 -7
  168. package/{fs → fjs}/website/proof.f.js +3 -6
  169. package/package.json +6 -6
  170. package/fs/asserts/module.f.d.ts +0 -4
  171. package/fs/asserts/module.f.js +0 -9
  172. package/fs/asserts/proof.f.d.ts +0 -8
  173. package/fs/asserts/proof.f.js +0 -51
  174. package/fs/bnf/data/module.f.d.ts +0 -30
  175. package/fs/bnf/descent/module.f.js +0 -119
  176. package/fs/bnf/proof.f.js +0 -104
  177. package/fs/cas/mcp/module.f.d.ts +0 -36
  178. package/fs/crypto/pow/proof.f.js +0 -161
  179. package/fs/djs/tokenizer/module.f.d.ts +0 -12
  180. package/fs/djs/tokenizer/module.f.js +0 -62
  181. package/fs/djs/tokenizer/proof.f.d.ts +0 -7
  182. package/fs/djs/tokenizer/proof.f.js +0 -543
  183. package/fs/djs/tokenizer-new/module.f.d.ts +0 -3
  184. package/fs/djs/tokenizer-new/module.f.js +0 -155
  185. package/fs/media/revision/proof.f.js +0 -119
  186. package/fs/text/ascii/proof.f.d.ts +0 -4
  187. package/fs/types/bigfloat/proof.f.js +0 -348
  188. package/fs/types/nullable/proof.f.js +0 -50
  189. package/fs/types/range/module.f.js +0 -2
  190. package/fs/types/range/proof.f.js +0 -18
  191. package/fs/types/result/proof.f.js +0 -52
  192. package/fs/types/string/proof.f.js +0 -118
  193. package/fs/types/string_set/proof.f.js +0 -82
  194. /package/{fs → fjs}/asn.1/module.f.d.ts +0 -0
  195. /package/{fs → fjs}/asn.1/module.f.js +0 -0
  196. /package/{fs → fjs}/asn.1/proof.f.d.ts +0 -0
  197. /package/{fs → fjs}/base_n/module.f.d.ts +0 -0
  198. /package/{fs → fjs}/base_n/module.f.js +0 -0
  199. /package/{fs → fjs}/base_n/proof.f.d.ts +0 -0
  200. /package/{fs → fjs}/basen/base128/module.f.d.ts +0 -0
  201. /package/{fs → fjs}/basen/base128/module.f.js +0 -0
  202. /package/{fs → fjs}/basen/base128/proof.f.d.ts +0 -0
  203. /package/{fs → fjs}/basen/base128/proof.f.js +0 -0
  204. /package/{fs → fjs}/basen/base64/module.f.d.ts +0 -0
  205. /package/{fs → fjs}/basen/base64/module.f.js +0 -0
  206. /package/{fs → fjs}/basen/cbase32/module.f.d.ts +0 -0
  207. /package/{fs → fjs}/basen/cbase32/module.f.js +0 -0
  208. /package/{fs → fjs}/basen/cbase32/proof.f.d.ts +0 -0
  209. /package/{fs → fjs}/bnf/proof.f.d.ts +0 -0
  210. /package/{fs → fjs}/bnf/testlib.f.d.ts +0 -0
  211. /package/{fs → fjs}/cas/cli/module.f.d.ts +0 -0
  212. /package/{fs → fjs}/cas/cli/module.f.js +0 -0
  213. /package/{fs → fjs}/ci/bun/module.f.d.ts +0 -0
  214. /package/{fs → fjs}/ci/bun/module.f.js +0 -0
  215. /package/{fs → fjs}/ci/common/module.f.d.ts +0 -0
  216. /package/{fs → fjs}/ci/common/module.f.js +0 -0
  217. /package/{fs → fjs}/ci/deno/module.f.d.ts +0 -0
  218. /package/{fs → fjs}/ci/deno/module.f.js +0 -0
  219. /package/{fs → fjs}/ci/module.f.d.ts +0 -0
  220. /package/{fs → fjs}/ci/module.f.js +0 -0
  221. /package/{fs → fjs}/ci/node/module.f.d.ts +0 -0
  222. /package/{fs → fjs}/ci/node/module.f.js +0 -0
  223. /package/{fs → fjs}/ci/playwright/module.f.d.ts +0 -0
  224. /package/{fs → fjs}/ci/playwright/module.f.js +0 -0
  225. /package/{fs → fjs}/ci/proof.f.d.ts +0 -0
  226. /package/{fs → fjs}/ci/rust/module.f.d.ts +0 -0
  227. /package/{fs → fjs}/cli/module.f.d.ts +0 -0
  228. /package/{fs → fjs}/cli/module.f.js +0 -0
  229. /package/{fs → fjs}/cli/proof.f.d.ts +0 -0
  230. /package/{fs → fjs}/common/monoid/module.f.d.ts +0 -0
  231. /package/{fs → fjs}/common/monoid/module.f.js +0 -0
  232. /package/{fs → fjs}/common/monoid/proof.f.d.ts +0 -0
  233. /package/{fs → fjs}/crypto/hmac/module.f.d.ts +0 -0
  234. /package/{fs → fjs}/crypto/hmac/module.f.js +0 -0
  235. /package/{fs → fjs}/crypto/hmac/proof.f.d.ts +0 -0
  236. /package/{fs → fjs}/crypto/pow/module.f.d.ts +0 -0
  237. /package/{fs → fjs}/crypto/pow/module.f.js +0 -0
  238. /package/{fs → fjs}/crypto/pow/proof.f.d.ts +0 -0
  239. /package/{fs → fjs}/crypto/secp/module.f.d.ts +0 -0
  240. /package/{fs → fjs}/crypto/secp/module.f.js +0 -0
  241. /package/{fs → fjs}/crypto/secp/proof.f.d.ts +0 -0
  242. /package/{fs → fjs}/crypto/sha2/module.f.d.ts +0 -0
  243. /package/{fs → fjs}/crypto/sha2/module.f.js +0 -0
  244. /package/{fs → fjs}/crypto/sha2/proof.f.d.ts +0 -0
  245. /package/{fs → fjs}/crypto/sign/proof.f.d.ts +0 -0
  246. /package/{fs → fjs}/crypto/vdf/module.f.d.ts +0 -0
  247. /package/{fs → fjs}/crypto/vdf/module.f.js +0 -0
  248. /package/{fs → fjs}/crypto/vdf/proof.f.d.ts +0 -0
  249. /package/{fs → fjs}/dev/module.f.d.ts +0 -0
  250. /package/{fs → fjs}/dev/module.f.js +0 -0
  251. /package/{fs → fjs}/dev/package_json/module.f.d.ts +0 -0
  252. /package/{fs → fjs}/dev/package_json/module.f.js +0 -0
  253. /package/{fs → fjs}/dev/package_json/proof.f.d.ts +0 -0
  254. /package/{fs → fjs}/dev/proof.f.d.ts +0 -0
  255. /package/{fs → fjs}/djs/ast/module.f.d.ts +0 -0
  256. /package/{fs → fjs}/djs/ast/module.f.js +0 -0
  257. /package/{fs → fjs}/djs/ast/proof.f.d.ts +0 -0
  258. /package/{fs → fjs}/djs/examples/input.f.d.ts +0 -0
  259. /package/{fs → fjs}/djs/examples/input.f.js +0 -0
  260. /package/{fs → fjs}/djs/examples/m.f.d.ts +0 -0
  261. /package/{fs → fjs}/djs/examples/m.f.js +0 -0
  262. /package/{fs → fjs}/djs/module.f.d.ts +0 -0
  263. /package/{fs → fjs}/djs/module.f.js +0 -0
  264. /package/{fs → fjs}/djs/parser/proof.f.d.ts +0 -0
  265. /package/{fs → fjs}/djs/proof.f.d.ts +0 -0
  266. /package/{fs → fjs}/djs/serializer/module.f.d.ts +0 -0
  267. /package/{fs → fjs}/djs/serializer/module.f.js +0 -0
  268. /package/{fs → fjs}/djs/serializer/proof.f.d.ts +0 -0
  269. /package/{fs → fjs}/djs/transpiler/module.f.d.ts +0 -0
  270. /package/{fs → fjs}/djs/transpiler/module.f.js +0 -0
  271. /package/{fs → fjs}/effects/list/module.f.d.ts +0 -0
  272. /package/{fs → fjs}/effects/list/module.f.js +0 -0
  273. /package/{fs → fjs}/effects/memory/module.f.d.ts +0 -0
  274. /package/{fs → fjs}/effects/memory/module.f.js +0 -0
  275. /package/{fs → fjs}/effects/memory/proof.f.d.ts +0 -0
  276. /package/{fs → fjs}/effects/mock/module.f.d.ts +0 -0
  277. /package/{fs → fjs}/effects/mock/module.f.js +0 -0
  278. /package/{fs → fjs}/effects/module.d.ts +0 -0
  279. /package/{fs → fjs}/effects/module.f.d.ts +0 -0
  280. /package/{fs → fjs}/effects/module.f.js +0 -0
  281. /package/{fs → fjs}/effects/module.js +0 -0
  282. /package/{fs → fjs}/effects/node/memory/module.d.ts +0 -0
  283. /package/{fs → fjs}/effects/node/memory/module.js +0 -0
  284. /package/{fs → fjs}/effects/node/memory/proof.d.ts +0 -0
  285. /package/{fs → fjs}/effects/node/module.f.js +0 -0
  286. /package/{fs → fjs}/effects/node/virtual/module.f.d.ts +0 -0
  287. /package/{fs → fjs}/effects/node/virtual/module.f.js +0 -0
  288. /package/{fs → fjs}/effects/proof.f.d.ts +0 -0
  289. /package/{fs → fjs}/emergent_testing/all.test.d.ts +0 -0
  290. /package/{fs → fjs}/emergent_testing/all.test.js +0 -0
  291. /package/{fs → fjs}/emergent_testing/example.f.d.ts +0 -0
  292. /package/{fs → fjs}/emergent_testing/example.f.js +0 -0
  293. /package/{fs → fjs}/emergent_testing/module.f.d.ts +0 -0
  294. /package/{fs → fjs}/emergent_testing/module.f.js +0 -0
  295. /package/{fs → fjs}/emergent_testing/proof.f.d.ts +0 -0
  296. /package/{fs → fjs}/emergent_testing/scenarios/all.d.ts +0 -0
  297. /package/{fs → fjs}/emergent_testing/scenarios/all.js +0 -0
  298. /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.fail.d.ts +0 -0
  299. /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.fail.js +0 -0
  300. /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.pass.d.ts +0 -0
  301. /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.pass.js +0 -0
  302. /package/{fs → fjs}/emergent_testing/scenarios/async.fail.d.ts +0 -0
  303. /package/{fs → fjs}/emergent_testing/scenarios/async.fail.js +0 -0
  304. /package/{fs → fjs}/emergent_testing/scenarios/async.pass.d.ts +0 -0
  305. /package/{fs → fjs}/emergent_testing/scenarios/async.pass.js +0 -0
  306. /package/{fs → fjs}/emergent_testing/scenarios/fail.fail.d.ts +0 -0
  307. /package/{fs → fjs}/emergent_testing/scenarios/fail.fail.js +0 -0
  308. /package/{fs → fjs}/emergent_testing/scenarios/return-value.pass.d.ts +0 -0
  309. /package/{fs → fjs}/emergent_testing/scenarios/return-value.pass.js +0 -0
  310. /package/{fs → fjs}/emergent_testing/scenarios/thenable.pass.d.ts +0 -0
  311. /package/{fs → fjs}/emergent_testing/scenarios/thenable.pass.js +0 -0
  312. /package/{fs → fjs}/emergent_testing/scenarios/thenable2.pass.d.ts +0 -0
  313. /package/{fs → fjs}/emergent_testing/scenarios/thenable2.pass.js +0 -0
  314. /package/{fs → fjs}/emergent_testing/scenarios/throw.pass.d.ts +0 -0
  315. /package/{fs → fjs}/emergent_testing/scenarios/throw.pass.js +0 -0
  316. /package/{fs → fjs}/fsc/bnf.f.d.ts +0 -0
  317. /package/{fs → fjs}/fsc/bnf.f.js +0 -0
  318. /package/{fs → fjs}/fsc/json.f.d.ts +0 -0
  319. /package/{fs → fjs}/fsc/json.f.js +0 -0
  320. /package/{fs → fjs}/fsc/module.f.d.ts +0 -0
  321. /package/{fs → fjs}/fsc/module.f.js +0 -0
  322. /package/{fs → fjs}/fsc/proof.f.d.ts +0 -0
  323. /package/{fs → fjs}/fsm/module.f.d.ts +0 -0
  324. /package/{fs → fjs}/fsm/module.f.js +0 -0
  325. /package/{fs → fjs}/fsm/proof.f.d.ts +0 -0
  326. /package/{fs → fjs}/js/tokenizer/module.f.d.ts +0 -0
  327. /package/{fs → fjs}/js/tokenizer/module.f.js +0 -0
  328. /package/{fs → fjs}/js/tokenizer/proof.f.d.ts +0 -0
  329. /package/{fs → fjs}/js/tokenizer/proof.f.js +0 -0
  330. /package/{fs → fjs}/mcp/proof.f.d.ts +0 -0
  331. /package/{fs → fjs}/mcp/stdio/proof.f.d.ts +0 -0
  332. /package/{fs → fjs}/mcp/stdio/proof.f.js +0 -0
  333. /package/{fs → fjs}/media/html/module.f.d.ts +0 -0
  334. /package/{fs → fjs}/media/html/module.f.js +0 -0
  335. /package/{fs → fjs}/media/html/proof.f.d.ts +0 -0
  336. /package/{fs → fjs}/media/json/module.f.d.ts +0 -0
  337. /package/{fs → fjs}/media/json/module.f.js +0 -0
  338. /package/{fs → fjs}/media/json/parser/proof.f.d.ts +0 -0
  339. /package/{fs → fjs}/media/json/proof.f.d.ts +0 -0
  340. /package/{fs → fjs}/media/json/proof.f.js +0 -0
  341. /package/{fs → fjs}/media/json/rpc/module.f.d.ts +0 -0
  342. /package/{fs → fjs}/media/json/rpc/proof.f.d.ts +0 -0
  343. /package/{fs → fjs}/media/json/rpc/proof.f.js +0 -0
  344. /package/{fs → fjs}/media/json/schema/proof.f.d.ts +0 -0
  345. /package/{fs → fjs}/media/json/serializer/module.f.d.ts +0 -0
  346. /package/{fs → fjs}/media/json/serializer/module.f.js +0 -0
  347. /package/{fs → fjs}/media/json/serializer/proof.f.d.ts +0 -0
  348. /package/{fs → fjs}/media/json/tokenizer/module.f.d.ts +0 -0
  349. /package/{fs → fjs}/media/json/tokenizer/module.f.js +0 -0
  350. /package/{fs → fjs}/media/json/tokenizer/proof.f.d.ts +0 -0
  351. /package/{fs → fjs}/media/json/tokenizer/proof.f.js +0 -0
  352. /package/{fs → fjs}/media/proof.f.d.ts +0 -0
  353. /package/{fs → fjs}/media/type/module.f.d.ts +0 -0
  354. /package/{fs → fjs}/media/type/module.f.js +0 -0
  355. /package/{fs → fjs}/media/type/proof.f.d.ts +0 -0
  356. /package/{fs → fjs}/module.d.ts +0 -0
  357. /package/{fs → fjs}/module.f.d.ts +0 -0
  358. /package/{fs → fjs}/module.js +0 -0
  359. /package/{fs → fjs}/path/module.f.d.ts +0 -0
  360. /package/{fs → fjs}/path/module.f.js +0 -0
  361. /package/{fs → fjs}/path/proof.f.d.ts +0 -0
  362. /package/{fs → fjs}/proof.f.d.ts +0 -0
  363. /package/{fs → fjs}/sul/id/module.f.d.ts +0 -0
  364. /package/{fs → fjs}/sul/id/module.f.js +0 -0
  365. /package/{fs → fjs}/sul/id/proof.f.d.ts +0 -0
  366. /package/{fs → fjs}/sul/level/hash/module.f.d.ts +0 -0
  367. /package/{fs → fjs}/sul/level/hash/module.f.js +0 -0
  368. /package/{fs → fjs}/sul/level/hash/proof.f.d.ts +0 -0
  369. /package/{fs → fjs}/sul/level/literal/module.f.d.ts +0 -0
  370. /package/{fs → fjs}/sul/level/literal/module.f.js +0 -0
  371. /package/{fs → fjs}/sul/level/literal/proof.f.d.ts +0 -0
  372. /package/{fs → fjs}/sul/module.f.d.ts +0 -0
  373. /package/{fs → fjs}/sul/module.f.js +0 -0
  374. /package/{fs → fjs}/sul/proof.f.d.ts +0 -0
  375. /package/{fs → fjs}/sul/proof.f.js +0 -0
  376. /package/{fs → fjs}/text/ascii/module.f.d.ts +0 -0
  377. /package/{fs → fjs}/text/ascii/module.f.js +0 -0
  378. /package/{fs → fjs}/text/code_point/module.f.d.ts +0 -0
  379. /package/{fs → fjs}/text/code_point/proof.f.d.ts +0 -0
  380. /package/{fs → fjs}/text/code_point/proof.f.js +0 -0
  381. /package/{fs → fjs}/text/module.f.d.ts +0 -0
  382. /package/{fs → fjs}/text/module.f.js +0 -0
  383. /package/{fs → fjs}/text/proof.f.d.ts +0 -0
  384. /package/{fs → fjs}/text/sgr/module.f.d.ts +0 -0
  385. /package/{fs → fjs}/text/sgr/module.f.js +0 -0
  386. /package/{fs → fjs}/text/sgr/proof.f.d.ts +0 -0
  387. /package/{fs → fjs}/text/utf16/module.f.d.ts +0 -0
  388. /package/{fs → fjs}/text/utf16/proof.f.d.ts +0 -0
  389. /package/{fs → fjs}/text/utf8/module.f.d.ts +0 -0
  390. /package/{fs → fjs}/text/utf8/module.f.js +0 -0
  391. /package/{fs → fjs}/text/utf8/proof.f.d.ts +0 -0
  392. /package/{fs → fjs}/types/array/module.f.d.ts +0 -0
  393. /package/{fs → fjs}/types/array/module.f.js +0 -0
  394. /package/{fs → fjs}/types/array/proof.f.d.ts +0 -0
  395. /package/{fs → fjs}/types/bigfloat/module.f.d.ts +0 -0
  396. /package/{fs → fjs}/types/bigfloat/module.f.js +0 -0
  397. /package/{fs → fjs}/types/bigfloat/proof.f.d.ts +0 -0
  398. /package/{fs → fjs}/types/bigint/module.f.d.ts +0 -0
  399. /package/{fs → fjs}/types/bigint/module.f.js +0 -0
  400. /package/{fs → fjs}/types/bigint/proof.f.d.ts +0 -0
  401. /package/{fs → fjs}/types/bit_vec/module.f.d.ts +0 -0
  402. /package/{fs → fjs}/types/bit_vec/module.f.js +0 -0
  403. /package/{fs → fjs}/types/bit_vec/proof.f.d.ts +0 -0
  404. /package/{fs → fjs}/types/btree/find/module.f.d.ts +0 -0
  405. /package/{fs → fjs}/types/btree/find/module.f.js +0 -0
  406. /package/{fs → fjs}/types/btree/find/proof.f.d.ts +0 -0
  407. /package/{fs → fjs}/types/btree/module.f.d.ts +0 -0
  408. /package/{fs → fjs}/types/btree/module.f.js +0 -0
  409. /package/{fs → fjs}/types/btree/proof.f.d.ts +0 -0
  410. /package/{fs → fjs}/types/btree/remove/module.f.d.ts +0 -0
  411. /package/{fs → fjs}/types/btree/remove/module.f.js +0 -0
  412. /package/{fs → fjs}/types/btree/set/module.f.d.ts +0 -0
  413. /package/{fs → fjs}/types/btree/set/proof.f.d.ts +0 -0
  414. /package/{fs → fjs}/types/btree/types/module.f.d.ts +0 -0
  415. /package/{fs → fjs}/types/btree/types/module.f.js +0 -0
  416. /package/{fs → fjs}/types/byte_set/module.f.d.ts +0 -0
  417. /package/{fs → fjs}/types/byte_set/module.f.js +0 -0
  418. /package/{fs → fjs}/types/byte_set/proof.f.d.ts +0 -0
  419. /package/{fs → fjs}/types/function/compare/module.f.d.ts +0 -0
  420. /package/{fs → fjs}/types/function/compare/module.f.js +0 -0
  421. /package/{fs → fjs}/types/function/compare/proof.f.d.ts +0 -0
  422. /package/{fs → fjs}/types/function/module.f.d.ts +0 -0
  423. /package/{fs → fjs}/types/function/module.f.js +0 -0
  424. /package/{fs → fjs}/types/function/operator/module.f.d.ts +0 -0
  425. /package/{fs → fjs}/types/function/operator/module.f.js +0 -0
  426. /package/{fs → fjs}/types/function/operator/proof.f.d.ts +0 -0
  427. /package/{fs → fjs}/types/function/proof.f.d.ts +0 -0
  428. /package/{fs → fjs}/types/list/module.f.d.ts +0 -0
  429. /package/{fs → fjs}/types/list/module.f.js +0 -0
  430. /package/{fs → fjs}/types/list/proof.f.d.ts +0 -0
  431. /package/{fs → fjs}/types/map/module.f.d.ts +0 -0
  432. /package/{fs → fjs}/types/map/module.f.js +0 -0
  433. /package/{fs → fjs}/types/map/proof.f.d.ts +0 -0
  434. /package/{fs → fjs}/types/nibble_set/module.f.d.ts +0 -0
  435. /package/{fs → fjs}/types/nibble_set/module.f.js +0 -0
  436. /package/{fs → fjs}/types/nibble_set/proof.f.d.ts +0 -0
  437. /package/{fs → fjs}/types/nominal/module.f.d.ts +0 -0
  438. /package/{fs → fjs}/types/nominal/module.f.js +0 -0
  439. /package/{fs → fjs}/types/nominal/proof.f.d.ts +0 -0
  440. /package/{fs → fjs}/types/nullable/module.f.d.ts +0 -0
  441. /package/{fs → fjs}/types/nullable/module.f.js +0 -0
  442. /package/{fs → fjs}/types/nullable/proof.f.d.ts +0 -0
  443. /package/{fs → fjs}/types/number/module.f.d.ts +0 -0
  444. /package/{fs → fjs}/types/number/module.f.js +0 -0
  445. /package/{fs → fjs}/types/number/proof.f.d.ts +0 -0
  446. /package/{fs → fjs}/types/object/module.f.d.ts +0 -0
  447. /package/{fs → fjs}/types/object/module.f.js +0 -0
  448. /package/{fs → fjs}/types/object/proof.f.d.ts +0 -0
  449. /package/{fs → fjs}/types/option/module.f.d.ts +0 -0
  450. /package/{fs → fjs}/types/option/module.f.js +0 -0
  451. /package/{fs → fjs}/types/ordered_map/module.f.d.ts +0 -0
  452. /package/{fs → fjs}/types/ordered_map/module.f.js +0 -0
  453. /package/{fs → fjs}/types/ordered_map/proof.f.d.ts +0 -0
  454. /package/{fs → fjs}/types/ordered_map/proof.f.js +0 -0
  455. /package/{fs → fjs}/types/patricia_trie/module.f.d.ts +0 -0
  456. /package/{fs → fjs}/types/patricia_trie/module.f.js +0 -0
  457. /package/{fs → fjs}/types/patricia_trie/proof.f.d.ts +0 -0
  458. /package/{fs → fjs}/types/phantom/module.f.d.ts +0 -0
  459. /package/{fs → fjs}/types/phantom/module.f.js +0 -0
  460. /package/{fs → fjs}/types/prime_field/module.f.d.ts +0 -0
  461. /package/{fs → fjs}/types/prime_field/proof.f.d.ts +0 -0
  462. /package/{fs → fjs}/types/prime_field/proof.f.js +0 -0
  463. /package/{fs → fjs}/types/range/proof.f.d.ts +0 -0
  464. /package/{fs → fjs}/types/range_map/module.f.d.ts +0 -0
  465. /package/{fs → fjs}/types/range_map/module.f.js +0 -0
  466. /package/{fs → fjs}/types/range_map/proof.f.d.ts +0 -0
  467. /package/{fs → fjs}/types/result/module.d.ts +0 -0
  468. /package/{fs → fjs}/types/result/module.f.d.ts +0 -0
  469. /package/{fs → fjs}/types/result/module.f.js +0 -0
  470. /package/{fs → fjs}/types/result/module.js +0 -0
  471. /package/{fs → fjs}/types/rtti/module.f.d.ts +0 -0
  472. /package/{fs → fjs}/types/rtti/module.f.js +0 -0
  473. /package/{fs → fjs}/types/rtti/parse/module.f.d.ts +0 -0
  474. /package/{fs → fjs}/types/rtti/parse/proof.f.d.ts +0 -0
  475. /package/{fs → fjs}/types/rtti/proof.f.d.ts +0 -0
  476. /package/{fs → fjs}/types/rtti/proof.f.js +0 -0
  477. /package/{fs → fjs}/types/rtti/ts/module.f.js +0 -0
  478. /package/{fs → fjs}/types/rtti/ts/proof.f.d.ts +0 -0
  479. /package/{fs → fjs}/types/rtti/ts/proof.f.js +0 -0
  480. /package/{fs → fjs}/types/rtti/validate/module.f.d.ts +0 -0
  481. /package/{fs → fjs}/types/rtti/validate/proof.f.d.ts +0 -0
  482. /package/{fs → fjs}/types/sorted_list/module.f.d.ts +0 -0
  483. /package/{fs → fjs}/types/sorted_list/module.f.js +0 -0
  484. /package/{fs → fjs}/types/sorted_list/proof.f.d.ts +0 -0
  485. /package/{fs → fjs}/types/sorted_set/module.f.d.ts +0 -0
  486. /package/{fs → fjs}/types/sorted_set/module.f.js +0 -0
  487. /package/{fs → fjs}/types/sorted_set/proof.f.d.ts +0 -0
  488. /package/{fs → fjs}/types/string/module.f.d.ts +0 -0
  489. /package/{fs → fjs}/types/string/module.f.js +0 -0
  490. /package/{fs → fjs}/types/string/proof.f.d.ts +0 -0
  491. /package/{fs → fjs}/types/string_set/module.f.d.ts +0 -0
  492. /package/{fs → fjs}/types/string_set/module.f.js +0 -0
  493. /package/{fs → fjs}/types/string_set/proof.f.d.ts +0 -0
  494. /package/{fs → fjs}/types/ts/module.f.d.ts +0 -0
  495. /package/{fs → fjs}/types/ts/module.f.js +0 -0
  496. /package/{fs → fjs}/types/ts/proof.f.d.ts +0 -0
  497. /package/{fs → fjs}/types/uint8array/module.f.d.ts +0 -0
  498. /package/{fs → fjs}/website/module.f.d.ts +0 -0
  499. /package/{fs → fjs}/website/module.f.js +0 -0
  500. /package/{fs → fjs}/website/proof.f.d.ts +0 -0
@@ -1,160 +1,13 @@
1
1
  import { descentParser } from '../../bnf/descent/module.f.js';
2
- import { backspace, ht, lf, ff, cr, quotationMark, solidus, reverseSolidus, digitRange, digit0, latinCapitalLetterA, latinSmallLetterA, latinSmallLetterB, latinSmallLetterF, latinSmallLetterN, latinSmallLetterR, latinSmallLetterT, latinSmallLetterU, range, } from '../../text/ascii/module.f.js';
3
- import { stringToCodePointList } from '../../text/utf16/module.f.js';
4
- import { contains } from '../../types/range/module.f.js';
5
- import { concat, filter, flat, flatMap, map, stateScan, toArray } from '../../types/list/module.f.js';
6
- import { jsGrammar, parse } from './module.f.js';
7
- const mapCodePoint = (cp) => [cp, undefined];
8
- const descentParserCpOnly = (m, name, cp) => {
9
- const cpm = toArray(map(mapCodePoint)(cp));
10
- return m(name, cpm);
11
- };
12
- const tokenizeString = s => {
13
- const m = descentParser(jsGrammar());
14
- const cp = toArray(stringToCodePointList(s));
15
- const [ast, ok, len] = descentParserCpOnly(m, '', cp);
16
- if (cp.length === 0) {
17
- return JSON.stringify([{ kind: 'eof' }]);
18
- }
19
- if (!ok)
20
- return 'error';
21
- if (cp.length > 0 && len !== cp.length)
22
- return 'error';
23
- const flatTokens = getTokensFromAstRule(ast);
24
- const filterTokens = concat(filter(filterFunc)(flatTokens))(['']);
25
- const tokens = flat(stateScan(scanFunc)(['', []])(filterTokens));
26
- const jsTokens = concat(map(toJsToken)(tokens))([{ kind: 'eof' }]);
27
- const result = toArray(filter(v => v !== null)(jsTokens));
28
- //return JSON.stringify(toArray(filterTokens))
29
- return JSON.stringify(result);
30
- };
31
- const isNlTag = (tag) => tag === '\n' || tag === '\r';
32
- const isWsTag = (tag) => tag === ' ' || tag === '\t';
33
- const scanFunc = (input, state) => {
34
- if (typeof input === 'string') {
35
- if (isNlTag(input) && isNlTag(state[0]))
36
- return [null, state];
37
- if (isWsTag(input) && isWsTag(state[0]))
38
- return [null, state];
39
- if (isNlTag(input) && isWsTag(state[0]))
40
- return [null, [input, []]];
41
- if (isWsTag(input) && isNlTag(state[0]))
42
- return [null, state];
43
- const newState = [input, []];
44
- if (state[0] === '') {
45
- return [null, newState];
46
- }
47
- const tk = [state[0], toArray(state[1])];
48
- return [[tk], newState];
49
- }
50
- return [null, [state[0], concat(state[1])([input])]];
51
- };
52
- // All operator tag strings produced by the grammar's operator rule
53
- const operatorTags = new Set([
54
- '.', '=>', '===', '==', '=', '!==', '!=', '!',
55
- '>>>=', '>>>', '>>=', '>>', '>=', '>',
56
- '<<<=', '<<<', '<<=', '<<', '<=', '<',
57
- '+=', '++', '+', '-=', '--', '-',
58
- '**=', '**', '*=', '*', '/=', '/', '%=', '%', // TODO: '/' here causes multi-char line comments (e.g. //ab\n) to fall through as two '/' operator tokens because the oneline rule only consumes one non-newline character (option vs repeat0Plus). Fix the comment rule to use repeat0Plus, or make filterFunc distinguish operator-branch '/' from slash characters inside comments.
59
- '&&=', '&&', '&=', '&', '||=', '||', '|=', '|',
60
- '^=', '^', '~', '??=', '??', '?.', '?',
61
- '[', ']', '{', '}', '(', ')', ',', ':'
62
- ]);
63
- const filterFunc = tk => {
64
- if (typeof tk === 'number')
65
- return true;
66
- switch (tk) {
67
- case 'number':
68
- case 'string':
69
- case 'id':
70
- case '\n':
71
- case '\r':
72
- case ' ':
73
- case '\t':
74
- return true;
75
- default:
76
- return operatorTags.has(tk);
77
- }
78
- };
79
- const rangeCapitalAF = range('AF');
80
- const stringDecodeScan = (cp, state) => {
81
- switch (state.kind) {
82
- case 'escape':
83
- switch (cp) {
84
- case quotationMark: return [[quotationMark], { kind: 'normal' }]; // \" → "
85
- case reverseSolidus: return [[reverseSolidus], { kind: 'normal' }]; // \\ → \
86
- case solidus: return [[solidus], { kind: 'normal' }]; // \/ → /
87
- case latinSmallLetterB: return [[backspace], { kind: 'normal' }]; // \b → backspace (BS)
88
- case latinSmallLetterF: return [[ff], { kind: 'normal' }]; // \f → form feed (FF)
89
- case latinSmallLetterN: return [[lf], { kind: 'normal' }]; // \n → line feed (LF)
90
- case latinSmallLetterR: return [[cr], { kind: 'normal' }]; // \r → carriage return (CR)
91
- case latinSmallLetterT: return [[ht], { kind: 'normal' }]; // \t → horizontal tab (HT)
92
- case latinSmallLetterU: return [null, { kind: 'unicode', acc: 0, count: 0 }]; // \u → start 4 hex digits
93
- default: return [[cp], { kind: 'normal' }];
94
- }
95
- case 'unicode': {
96
- // convert hex digit char to its numeric value: '0'-'9', 'A'-'F', 'a'-'f'
97
- const digit = contains(digitRange)(cp) ? cp - digit0
98
- : contains(rangeCapitalAF)(cp) ? cp - (latinCapitalLetterA - 10)
99
- : cp - (latinSmallLetterA - 10);
100
- const acc = (state.acc << 4) | digit;
101
- return state.count === 3 ? [[acc], { kind: 'normal' }] : [null, { kind: 'unicode', acc, count: state.count + 1 }];
102
- }
103
- default:
104
- return cp === reverseSolidus ? [null, { kind: 'escape' }] : [[cp], { kind: 'normal' }];
105
- }
106
- };
107
- const decodeJsonString = codePoints => String.fromCodePoint(...toArray(flat(stateScan(stringDecodeScan)({ kind: 'normal' })(codePoints.slice(1, -1)))));
108
- const keywords = new Set([
109
- 'true', 'false', 'null', 'undefined',
110
- 'arguments', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue',
111
- 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'eval', 'export',
112
- 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in',
113
- 'instanceof', 'interface', 'let', 'new', 'package', 'private', 'protected',
114
- 'public', 'return', 'static', 'super', 'switch', 'this', 'throw', 'try',
115
- 'typeof', 'var', 'void', 'while', 'with', 'yield',
116
- ]);
117
- const toJsToken = tk => {
118
- switch (tk[0]) {
119
- case '\n':
120
- case '\r':
121
- return { kind: 'nl' };
122
- case ' ':
123
- case '\t':
124
- return { kind: 'ws' };
125
- case 'string':
126
- return { kind: 'string', value: decodeJsonString(tk[1]) };
127
- case 'id': {
128
- const value = String.fromCodePoint(...tk[1]);
129
- if (keywords.has(value))
130
- return { kind: value };
131
- return { kind: 'id', value };
132
- }
133
- default:
134
- return { kind: tk[0] };
135
- }
136
- };
137
- const getTokensFromAstRuleOrCodePoint = value => {
138
- if (value instanceof Array)
139
- return [value[0]];
140
- return getTokensFromAstRule(value);
141
- };
142
- const getTokensFromAstSequence = seq => {
143
- return flatMap(getTokensFromAstRuleOrCodePoint)(seq);
144
- };
145
- const tagToToken = tag => {
146
- switch (typeof tag) {
147
- case 'string': return tag;
148
- case 'undefined': return 'undefined';
149
- default: return 'true';
150
- }
151
- };
152
- const getTokensFromAstRule = ast => {
153
- const token = tagToToken(ast.tag);
154
- if (ast.sequence.length === 0)
155
- return [token];
156
- return { first: token, tail: getTokensFromAstSequence(ast.sequence) };
157
- };
2
+ import { stringToCodePointList, stringToList } from '../../text/utf16/module.f.js';
3
+ import { toArray } from '../../types/list/module.f.js';
4
+ import { jsGrammar, tokenizeString, descentParserCpOnly, tokenizeJs, tokenize } from './module.f.js';
5
+ import { assert, assertEq } from '../../asserts/module.f.js';
6
+ import { stringifyAsTree } from '../serializer/module.f.js';
7
+ import { sort } from '../../types/object/module.f.js';
8
+ // DjsTokenWithMetadata carries bigint fields (bf, bigint value) that JSON.stringify can't
9
+ // serialize reuse the same djs stringifyAsTree serializer tokenizeString uses internally.
10
+ const stringify = stringifyAsTree(sort);
158
11
  export const proof = {
159
12
  isValid: [() => {
160
13
  const m = descentParser(jsGrammar());
@@ -162,9 +15,7 @@ export const proof = {
162
15
  const cp = toArray(stringToCodePointList(s));
163
16
  const mr = descentParserCpOnly(m, '', cp);
164
17
  const success = mr[1] && mr[2] === cp.length;
165
- if (success !== expected) {
166
- throw JSON.stringify([s, mr]);
167
- }
18
+ assertEq(success, expected, JSON.stringify([s, mr]));
168
19
  };
169
20
  expect('"', false);
170
21
  expect(' true ', true);
@@ -201,150 +52,120 @@ export const proof = {
201
52
  const cp = toArray(stringToCodePointList('tr'));
202
53
  const mr = descentParserCpOnly(m, '', cp);
203
54
  const seq = mr[0].sequence[0];
204
- if (seq instanceof Array)
205
- throw JSON.stringify(mr);
206
- if (seq.tag !== 'id')
207
- throw JSON.stringify(mr);
55
+ assert(!(seq instanceof Array), JSON.stringify(mr));
56
+ assertEq(seq.tag, 'id', JSON.stringify(mr));
208
57
  },
209
58
  () => {
210
59
  const m = descentParser(jsGrammar());
211
60
  const cp = toArray(stringToCodePointList('"tr"'));
212
61
  const mr = descentParserCpOnly(m, '', cp);
213
62
  const seq = mr[0].sequence[0];
214
- if (seq instanceof Array)
215
- throw JSON.stringify(mr);
216
- if (seq.tag !== 'string')
217
- throw JSON.stringify(mr);
63
+ assert(!(seq instanceof Array), JSON.stringify(mr));
64
+ assertEq(seq.tag, 'string', JSON.stringify(mr));
218
65
  },
219
66
  () => {
220
67
  const m = descentParser(jsGrammar());
221
68
  const cp = toArray(stringToCodePointList('56.7e+5'));
222
69
  const mr = descentParserCpOnly(m, '', cp);
223
70
  const seq = mr[0].sequence[0];
224
- if (seq instanceof Array)
225
- throw JSON.stringify(mr);
226
- if (seq.tag !== 'number')
227
- throw JSON.stringify(mr);
71
+ assert(!(seq instanceof Array), JSON.stringify(mr));
72
+ assertEq(seq.tag, 'number', JSON.stringify(mr));
228
73
  },
229
74
  () => {
230
75
  const m = descentParser(jsGrammar());
231
76
  const cp = toArray(stringToCodePointList('56n'));
232
77
  const mr = descentParserCpOnly(m, '', cp);
233
78
  const seq = mr[0].sequence[0];
234
- if (seq instanceof Array)
235
- throw JSON.stringify(mr);
236
- if (seq.tag !== 'number')
237
- throw JSON.stringify(mr);
79
+ assert(!(seq instanceof Array), JSON.stringify(mr));
80
+ assertEq(seq.tag, 'number', JSON.stringify(mr));
238
81
  },
239
82
  () => {
240
83
  const m = descentParser(jsGrammar());
241
84
  const cp = toArray(stringToCodePointList('*'));
242
85
  const mr = descentParserCpOnly(m, '', cp);
243
86
  const seq = mr[0].sequence[0];
244
- if (seq instanceof Array)
245
- throw JSON.stringify(mr);
246
- if (seq.tag !== '*')
247
- throw JSON.stringify(mr);
87
+ assert(!(seq instanceof Array), JSON.stringify(mr));
88
+ assertEq(seq.tag, '*', JSON.stringify(mr));
248
89
  },
249
90
  () => {
250
91
  const m = descentParser(jsGrammar());
251
92
  const cp = toArray(stringToCodePointList('**'));
252
93
  const mr = descentParserCpOnly(m, '', cp);
253
94
  const seq = mr[0].sequence[0];
254
- if (seq instanceof Array)
255
- throw JSON.stringify(mr);
256
- if (seq.tag !== '**')
257
- throw JSON.stringify(mr);
95
+ assert(!(seq instanceof Array), JSON.stringify(mr));
96
+ assertEq(seq.tag, '**', JSON.stringify(mr));
258
97
  },
259
98
  () => {
260
99
  const m = descentParser(jsGrammar());
261
100
  const cp = toArray(stringToCodePointList('=>'));
262
101
  const mr = descentParserCpOnly(m, '', cp);
263
102
  const seq = mr[0].sequence[0];
264
- if (seq instanceof Array)
265
- throw JSON.stringify(mr);
266
- if (seq.tag !== '=>')
267
- throw JSON.stringify(mr);
103
+ assert(!(seq instanceof Array), JSON.stringify(mr));
104
+ assertEq(seq.tag, '=>', JSON.stringify(mr));
268
105
  },
269
106
  () => {
270
107
  const m = descentParser(jsGrammar());
271
108
  const cp = toArray(stringToCodePointList('=='));
272
109
  const mr = descentParserCpOnly(m, '', cp);
273
110
  const seq = mr[0].sequence[0];
274
- if (seq instanceof Array)
275
- throw JSON.stringify(mr);
276
- if (seq.tag !== '==')
277
- throw JSON.stringify(mr);
111
+ assert(!(seq instanceof Array), JSON.stringify(mr));
112
+ assert(!(seq.tag !== '=='), JSON.stringify(mr));
278
113
  },
279
114
  () => {
280
115
  const m = descentParser(jsGrammar());
281
116
  const cp = toArray(stringToCodePointList('==='));
282
117
  const mr = descentParserCpOnly(m, '', cp);
283
118
  const seq = mr[0].sequence[0];
284
- if (seq instanceof Array)
285
- throw JSON.stringify(mr);
286
- if (seq.tag !== '===')
287
- throw JSON.stringify(mr);
119
+ assert(!(seq instanceof Array), JSON.stringify(mr));
120
+ assert(!(seq.tag !== '==='), JSON.stringify(mr));
288
121
  },
289
122
  () => {
290
123
  const m = descentParser(jsGrammar());
291
124
  const cp = toArray(stringToCodePointList('='));
292
125
  const mr = descentParserCpOnly(m, '', cp);
293
126
  const seq = mr[0].sequence[0];
294
- if (seq instanceof Array)
295
- throw JSON.stringify(mr);
296
- if (seq.tag !== '=')
297
- throw JSON.stringify(mr);
127
+ assert(!(seq instanceof Array), JSON.stringify(mr));
128
+ assertEq(seq.tag, '=', JSON.stringify(mr));
298
129
  },
299
130
  () => {
300
131
  const m = descentParser(jsGrammar());
301
132
  const cp = toArray(stringToCodePointList(' '));
302
133
  const mr = descentParserCpOnly(m, '', cp);
303
134
  const seq = mr[0].sequence[0];
304
- if (seq instanceof Array)
305
- throw JSON.stringify(mr);
306
- if (seq.tag !== ' ')
307
- throw JSON.stringify(mr);
135
+ assert(!(seq instanceof Array), JSON.stringify(mr));
136
+ assertEq(seq.tag, ' ', JSON.stringify(mr));
308
137
  },
309
138
  () => {
310
139
  const m = descentParser(jsGrammar());
311
140
  const cp = toArray(stringToCodePointList('\n'));
312
141
  const mr = descentParserCpOnly(m, '', cp);
313
142
  const seq = mr[0].sequence[0];
314
- if (seq instanceof Array)
315
- throw JSON.stringify(mr);
316
- if (seq.tag !== '\n')
317
- throw JSON.stringify(mr);
143
+ assert(!(seq instanceof Array), JSON.stringify(mr));
144
+ assertEq(seq.tag, '\n', JSON.stringify(mr));
318
145
  },
319
146
  () => {
320
147
  const m = descentParser(jsGrammar());
321
148
  const cp = toArray(stringToCodePointList('/\n'));
322
149
  const mr = descentParserCpOnly(m, '', cp);
323
150
  const seq = mr[0].sequence[0];
324
- if (seq instanceof Array)
325
- throw JSON.stringify(mr);
326
- if (seq.tag !== '/')
327
- throw JSON.stringify(mr);
151
+ assert(!(seq instanceof Array), JSON.stringify(mr));
152
+ assertEq(seq.tag, '/', JSON.stringify(mr));
328
153
  },
329
154
  () => {
330
155
  const m = descentParser(jsGrammar());
331
156
  const cp = toArray(stringToCodePointList('//\n'));
332
157
  const mr = descentParserCpOnly(m, '', cp);
333
158
  const seq = mr[0].sequence[0];
334
- if (seq instanceof Array)
335
- throw JSON.stringify(mr);
336
- if (seq.tag !== 'comment')
337
- throw JSON.stringify(mr);
159
+ assert(!(seq instanceof Array), JSON.stringify(mr));
160
+ assertEq(seq.tag, 'comment', JSON.stringify(mr));
338
161
  },
339
162
  () => {
340
163
  const m = descentParser(jsGrammar());
341
164
  const cp = toArray(stringToCodePointList('/*1*/'));
342
165
  const mr = descentParserCpOnly(m, '', cp);
343
166
  const seq = mr[0].sequence[0];
344
- if (seq instanceof Array)
345
- throw JSON.stringify(mr);
346
- if (seq.tag !== 'comment')
347
- throw JSON.stringify(mr);
167
+ assert(!(seq instanceof Array), JSON.stringify(mr));
168
+ assertEq(seq.tag, 'comment', JSON.stringify(mr));
348
169
  }
349
170
  ],
350
171
  djs: [
@@ -392,9 +213,7 @@ export const proof = {
392
213
  },
393
214
  () => {
394
215
  const result = tokenizeString('ᄑ');
395
- if (result !== 'error') {
396
- throw result;
397
- }
216
+ assertEq(result, 'error');
398
217
  },
399
218
  () => {
400
219
  const result = tokenizeString('{ \t\n\r}');
@@ -416,9 +235,7 @@ export const proof = {
416
235
  },
417
236
  () => {
418
237
  const result = tokenizeString('"value');
419
- if (result !== 'error') {
420
- throw result;
421
- }
238
+ assertEq(result, 'error');
422
239
  },
423
240
  () => {
424
241
  const result = tokenizeString('"value1" "value2"');
@@ -428,9 +245,7 @@ export const proof = {
428
245
  },
429
246
  () => {
430
247
  const result = tokenizeString('"');
431
- if (result !== 'error') {
432
- throw result;
433
- }
248
+ assertEq(result, 'error');
434
249
  },
435
250
  () => {
436
251
  const result = tokenizeString('"\\\\"');
@@ -452,27 +267,19 @@ export const proof = {
452
267
  },
453
268
  () => {
454
269
  const result = tokenizeString('"\\x"');
455
- if (result !== 'error') {
456
- throw result;
457
- }
270
+ assertEq(result, 'error');
458
271
  },
459
272
  () => {
460
273
  const result = tokenizeString('"\\');
461
- if (result !== 'error') {
462
- throw result;
463
- }
274
+ assertEq(result, 'error');
464
275
  },
465
276
  () => {
466
277
  const result = tokenizeString('"\r"');
467
- if (result !== 'error') {
468
- throw result;
469
- }
278
+ assertEq(result, 'error');
470
279
  },
471
280
  () => {
472
281
  const result = tokenizeString('"\n null');
473
- if (result !== 'error') {
474
- throw result;
475
- }
282
+ assertEq(result, 'error');
476
283
  },
477
284
  () => {
478
285
  const result = tokenizeString('"\\b\\f\\n\\r\\t"');
@@ -494,130 +301,166 @@ export const proof = {
494
301
  },
495
302
  () => {
496
303
  const result = tokenizeString('"\\uEeFg"');
497
- if (result !== 'error') {
498
- throw result;
499
- }
500
- },
501
- // () => {
502
- // const result = tokenizeString('0')
503
- // if (result !== '[{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
504
- // },
505
- // () => {
506
- // const result = tokenizeString('[0]')
507
- // if (result !== '[{"kind":"["},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"]"},{"kind":"eof"}]') { throw result }
508
- // },
509
- // () => {
510
- // const result = tokenizeString('00')
511
- // if (result !== 'error') { throw result }
512
- // },
513
- // () => {
514
- // const result = tokenizeString('0abc,')
515
- // if (result !== 'error') { throw result }
516
- // },
517
- // () => {
518
- // const result = tokenizeString('123456789012345678901234567890')
519
- // if (result !== '[{"bf":[123456789012345678901234567890n,0],"kind":"number","value":"123456789012345678901234567890"},{"kind":"eof"}]') { throw result }
520
- // },
521
- // () => {
522
- // const result = tokenizeString('{90}')
523
- // if (result !== '[{"kind":"{"},{"bf":[90n,0],"kind":"number","value":"90"},{"kind":"}"},{"kind":"eof"}]') { throw result }
524
- // },
525
- // () => {
526
- // const result = tokenizeString('1 2')
527
- // if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"ws"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') { throw result }
528
- // },
529
- // () => {
530
- // const result = tokenizeString('0. 2')
531
- // if (result !== 'error') { throw result }
532
- // },
533
- // () => {
534
- // const result = tokenizeString('10-0')
535
- // if (result !== '[{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
536
- // },
537
- // () => {
538
- // const result = tokenizeString('9a:')
539
- // if (result !== 'error') { throw result }
540
- // },
541
- // () => {
542
- // const result = tokenizeString('-10')
543
- // if (result !== '[{"kind":"-"},{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"eof"}]') { throw result }
544
- // },
545
- // () => {
546
- // const result = tokenizeString('-0')
547
- // if (result !== '[{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
548
- // },
549
- // () => {
550
- // const result = tokenizeString('-00')
551
- // if (result !== 'error') { throw result }
552
- // },
553
- // () => {
554
- // const result = tokenizeString('-.123')
555
- // if (result !== '[{"kind":"-"},{"kind":"."},{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"eof"}]') { throw result }
556
- // },
557
- // () => {
558
- // const result = tokenizeString('0.01')
559
- // if (result !== '[{"bf":[1n,-2],"kind":"number","value":"0.01"},{"kind":"eof"}]') { throw result }
560
- // },
561
- // () => {
562
- // const result = tokenizeString('-0.9')
563
- // if (result !== '[{"kind":"-"},{"bf":[9n,-1],"kind":"number","value":"0.9"},{"kind":"eof"}]') { throw result }
564
- // },
565
- // () => {
566
- // const result = tokenizeString('-0.')
567
- // if (result !== 'error') { throw result }
568
- // },
569
- // () => {
570
- // const result = tokenizeString('-0.]')
571
- // if (result !== 'error') { throw result }
572
- // },
573
- // () => {
574
- // const result = tokenizeString('12.34')
575
- // if (result !== '[{"bf":[1234n,-2],"kind":"number","value":"12.34"},{"kind":"eof"}]') { throw result }
576
- // },
577
- // () => {
578
- // const result = tokenizeString('-12.00')
579
- // if (result !== '[{"kind":"-"},{"bf":[1200n,-2],"kind":"number","value":"12.00"},{"kind":"eof"}]') { throw result }
580
- // },
581
- // () => {
582
- // const result = tokenizeString('-12.')
583
- // if (result !== 'error') { throw result }
584
- // },
585
- // () => {
586
- // const result = tokenizeString('12.]')
587
- // if (result !== 'error') { throw result }
588
- // },
589
- // () => {
590
- // const result = tokenizeString('0e1')
591
- // if (result !== '[{"bf":[0n,1],"kind":"number","value":"0e1"},{"kind":"eof"}]') { throw result }
592
- // },
593
- // () => {
594
- // const result = tokenizeString('0e+2')
595
- // if (result !== '[{"bf":[0n,2],"kind":"number","value":"0e+2"},{"kind":"eof"}]') { throw result }
596
- // },
597
- // () => {
598
- // const result = tokenizeString('0e-0')
599
- // if (result !== '[{"bf":[0n,0],"kind":"number","value":"0e-0"},{"kind":"eof"}]') { throw result }
600
- // },
601
- // () => {
602
- // const result = tokenizeString('12e0000')
603
- // if (result !== '[{"bf":[12n,0],"kind":"number","value":"12e0000"},{"kind":"eof"}]') { throw result }
604
- // },
605
- // () => {
606
- // const result = tokenizeString('-12e-0001')
607
- // if (result !== '[{"kind":"-"},{"bf":[12n,-1],"kind":"number","value":"12e-0001"},{"kind":"eof"}]') { throw result }
608
- // },
609
- // () => {
610
- // const result = tokenizeString('-12.34e1234')
611
- // if (result !== '[{"kind":"-"},{"bf":[1234n,1232],"kind":"number","value":"12.34e1234"},{"kind":"eof"}]') { throw result }
612
- // },
613
- // () => {
614
- // const result = tokenizeString('0e')
615
- // if (result !== 'error') { throw result }
616
- // },
617
- // () => {
618
- // const result = tokenizeString('0e-')
619
- // if (result !== 'error') { throw result }
620
- // },
304
+ assertEq(result, 'error');
305
+ },
306
+ () => {
307
+ const result = tokenizeString('0');
308
+ if (result !== '[{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
309
+ throw result;
310
+ }
311
+ },
312
+ () => {
313
+ const result = tokenizeString('[0]');
314
+ if (result !== '[{"kind":"["},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"]"},{"kind":"eof"}]') {
315
+ throw result;
316
+ }
317
+ },
318
+ () => {
319
+ const result = tokenizeString('00');
320
+ assertEq(result, 'error');
321
+ },
322
+ () => {
323
+ const result = tokenizeString('0abc,');
324
+ assertEq(result, 'error');
325
+ },
326
+ () => {
327
+ const result = tokenizeString('123456789012345678901234567890');
328
+ if (result !== '[{"bf":[123456789012345678901234567890n,0],"kind":"number","value":"123456789012345678901234567890"},{"kind":"eof"}]') {
329
+ throw result;
330
+ }
331
+ },
332
+ () => {
333
+ const result = tokenizeString('{90}');
334
+ if (result !== '[{"kind":"{"},{"bf":[90n,0],"kind":"number","value":"90"},{"kind":"}"},{"kind":"eof"}]') {
335
+ throw result;
336
+ }
337
+ },
338
+ () => {
339
+ const result = tokenizeString('1 2');
340
+ if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"ws"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') {
341
+ throw result;
342
+ }
343
+ },
344
+ () => {
345
+ const result = tokenizeString('0. 2');
346
+ assertEq(result, 'error');
347
+ },
348
+ () => {
349
+ const result = tokenizeString('10-0');
350
+ if (result !== '[{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
351
+ throw result;
352
+ }
353
+ },
354
+ () => {
355
+ const result = tokenizeString('9a:');
356
+ assertEq(result, 'error');
357
+ },
358
+ () => {
359
+ const result = tokenizeString('-10');
360
+ if (result !== '[{"kind":"-"},{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"eof"}]') {
361
+ throw result;
362
+ }
363
+ },
364
+ () => {
365
+ const result = tokenizeString('-0');
366
+ if (result !== '[{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
367
+ throw result;
368
+ }
369
+ },
370
+ () => {
371
+ const result = tokenizeString('-00');
372
+ assertEq(result, 'error');
373
+ },
374
+ () => {
375
+ const result = tokenizeString('-.123');
376
+ if (result !== '[{"kind":"-"},{"kind":"."},{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"eof"}]') {
377
+ throw result;
378
+ }
379
+ },
380
+ () => {
381
+ const result = tokenizeString('0.01');
382
+ if (result !== '[{"bf":[1n,-2],"kind":"number","value":"0.01"},{"kind":"eof"}]') {
383
+ throw result;
384
+ }
385
+ },
386
+ () => {
387
+ const result = tokenizeString('-0.9');
388
+ if (result !== '[{"kind":"-"},{"bf":[9n,-1],"kind":"number","value":"0.9"},{"kind":"eof"}]') {
389
+ throw result;
390
+ }
391
+ },
392
+ () => {
393
+ const result = tokenizeString('-0.');
394
+ assertEq(result, 'error');
395
+ },
396
+ () => {
397
+ const result = tokenizeString('-0.]');
398
+ assertEq(result, 'error');
399
+ },
400
+ () => {
401
+ const result = tokenizeString('12.34');
402
+ if (result !== '[{"bf":[1234n,-2],"kind":"number","value":"12.34"},{"kind":"eof"}]') {
403
+ throw result;
404
+ }
405
+ },
406
+ () => {
407
+ const result = tokenizeString('-12.00');
408
+ if (result !== '[{"kind":"-"},{"bf":[1200n,-2],"kind":"number","value":"12.00"},{"kind":"eof"}]') {
409
+ throw result;
410
+ }
411
+ },
412
+ () => {
413
+ const result = tokenizeString('-12.');
414
+ assertEq(result, 'error');
415
+ },
416
+ () => {
417
+ const result = tokenizeString('12.]');
418
+ assertEq(result, 'error');
419
+ },
420
+ () => {
421
+ const result = tokenizeString('0e1');
422
+ if (result !== '[{"bf":[0n,1],"kind":"number","value":"0e1"},{"kind":"eof"}]') {
423
+ throw result;
424
+ }
425
+ },
426
+ () => {
427
+ const result = tokenizeString('0e+2');
428
+ if (result !== '[{"bf":[0n,2],"kind":"number","value":"0e+2"},{"kind":"eof"}]') {
429
+ throw result;
430
+ }
431
+ },
432
+ () => {
433
+ const result = tokenizeString('0e-0');
434
+ if (result !== '[{"bf":[0n,0],"kind":"number","value":"0e-0"},{"kind":"eof"}]') {
435
+ throw result;
436
+ }
437
+ },
438
+ () => {
439
+ const result = tokenizeString('12e0000');
440
+ if (result !== '[{"bf":[12n,0],"kind":"number","value":"12e0000"},{"kind":"eof"}]') {
441
+ throw result;
442
+ }
443
+ },
444
+ () => {
445
+ const result = tokenizeString('-12e-0001');
446
+ if (result !== '[{"kind":"-"},{"bf":[12n,-1],"kind":"number","value":"12e-0001"},{"kind":"eof"}]') {
447
+ throw result;
448
+ }
449
+ },
450
+ () => {
451
+ const result = tokenizeString('-12.34e1234');
452
+ if (result !== '[{"kind":"-"},{"bf":[1234n,1232],"kind":"number","value":"12.34e1234"},{"kind":"eof"}]') {
453
+ throw result;
454
+ }
455
+ },
456
+ () => {
457
+ const result = tokenizeString('0e');
458
+ assertEq(result, 'error');
459
+ },
460
+ () => {
461
+ const result = tokenizeString('0e-');
462
+ assertEq(result, 'error');
463
+ },
621
464
  () => {
622
465
  const result = tokenizeString('ABCdef1234567890$_');
623
466
  if (result !== '[{"kind":"id","value":"ABCdef1234567890$_"},{"kind":"eof"}]') {
@@ -630,50 +473,60 @@ export const proof = {
630
473
  throw result;
631
474
  }
632
475
  },
633
- // () => {
634
- // const result = tokenizeString('123 _123')
635
- // if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"_123"},{"kind":"eof"}]') { throw result }
636
- // },
637
- // () => {
638
- // const result = tokenizeString('123 $123')
639
- // if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"$123"},{"kind":"eof"}]') { throw result }
640
- // },
641
- // () => {
642
- // const result = tokenizeString('123_123')
643
- // if (result !== 'error') { throw result }
644
- // },
645
- // () => {
646
- // const result = tokenizeString('123$123')
647
- // if (result !== 'error') { throw result }
648
- // },
649
- // () => {
650
- // const result = tokenizeString('1234567890n')
651
- // if (result !== '[{"kind":"bigint","value":1234567890n},{"kind":"eof"}]') { throw result }
652
- // },
653
- // () => {
654
- // const result = tokenizeString('0n')
655
- // if (result !== '[{"kind":"bigint","value":0n},{"kind":"eof"}]') { throw result }
656
- // },
657
- // () => {
658
- // const result = tokenizeString('[-1234567890n]')
659
- // if (result !== '[{"kind":"["},{"kind":"-"},{"kind":"bigint","value":1234567890n},{"kind":"]"},{"kind":"eof"}]') { throw result }
660
- // },
661
- // () => {
662
- // const result = tokenizeString('123.456n')
663
- // if (result !== 'error') { throw result }
664
- // },
665
- // () => {
666
- // const result = tokenizeString('123e456n')
667
- // if (result !== 'error') { throw result }
668
- // },
669
- // () => {
670
- // const result = tokenizeString('1234567890na')
671
- // if (result !== 'error') { throw result }
672
- // },
673
- // () => {
674
- // const result = tokenizeString('1234567890nn')
675
- // if (result !== 'error') { throw result }
676
- // },
476
+ () => {
477
+ const result = tokenizeString('123 _123');
478
+ if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"_123"},{"kind":"eof"}]') {
479
+ throw result;
480
+ }
481
+ },
482
+ () => {
483
+ const result = tokenizeString('123 $123');
484
+ if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"$123"},{"kind":"eof"}]') {
485
+ throw result;
486
+ }
487
+ },
488
+ () => {
489
+ const result = tokenizeString('123_123');
490
+ assertEq(result, 'error');
491
+ },
492
+ () => {
493
+ const result = tokenizeString('123$123');
494
+ assertEq(result, 'error');
495
+ },
496
+ () => {
497
+ const result = tokenizeString('1234567890n');
498
+ if (result !== '[{"kind":"bigint","value":1234567890n},{"kind":"eof"}]') {
499
+ throw result;
500
+ }
501
+ },
502
+ () => {
503
+ const result = tokenizeString('0n');
504
+ if (result !== '[{"kind":"bigint","value":0n},{"kind":"eof"}]') {
505
+ throw result;
506
+ }
507
+ },
508
+ () => {
509
+ const result = tokenizeString('[-1234567890n]');
510
+ if (result !== '[{"kind":"["},{"kind":"-"},{"kind":"bigint","value":1234567890n},{"kind":"]"},{"kind":"eof"}]') {
511
+ throw result;
512
+ }
513
+ },
514
+ () => {
515
+ const result = tokenizeString('123.456n');
516
+ assertEq(result, 'error');
517
+ },
518
+ () => {
519
+ const result = tokenizeString('123e456n');
520
+ assertEq(result, 'error');
521
+ },
522
+ () => {
523
+ const result = tokenizeString('1234567890na');
524
+ assertEq(result, 'error');
525
+ },
526
+ () => {
527
+ const result = tokenizeString('1234567890nn');
528
+ assertEq(result, 'error');
529
+ },
677
530
  ],
678
531
  operators: [
679
532
  () => {
@@ -694,10 +547,12 @@ export const proof = {
694
547
  throw result;
695
548
  }
696
549
  },
697
- // () => {
698
- // const result = tokenizeString('1*2')
699
- // if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"*"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') { throw result }
700
- // },
550
+ () => {
551
+ const result = tokenizeString('1*2');
552
+ if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"*"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') {
553
+ throw result;
554
+ }
555
+ },
701
556
  () => {
702
557
  const result = tokenizeString('( )');
703
558
  if (result !== '[{"kind":"("},{"kind":"ws"},{"kind":")"},{"kind":"eof"}]') {
@@ -734,6 +589,14 @@ export const proof = {
734
589
  throw result;
735
590
  }
736
591
  },
592
+ () => {
593
+ // '<<<' and '<<<=' are not JS operators; maximal munch tokenizes them
594
+ // as '<<' followed by '<' / '<=', matching the old tokenizer's behavior.
595
+ const result = tokenizeString('<<< <<<=');
596
+ if (result !== '[{"kind":"<<"},{"kind":"<"},{"kind":"ws"},{"kind":"<<"},{"kind":"<="},{"kind":"eof"}]') {
597
+ throw result;
598
+ }
599
+ },
737
600
  () => {
738
601
  const result = tokenizeString('&& || ! ??');
739
602
  if (result !== '[{"kind":"&&"},{"kind":"ws"},{"kind":"||"},{"kind":"ws"},{"kind":"!"},{"kind":"ws"},{"kind":"??"},{"kind":"eof"}]') {
@@ -1113,37 +976,175 @@ export const proof = {
1113
976
  }
1114
977
  },
1115
978
  ],
1116
- throw: {
1117
- parse: () => { parse(''); }
1118
- },
1119
- // comments: [
1120
- // () => {
1121
- // const result = tokenizeString('//singleline comment')
1122
- // if (result !== '[{"kind":"//","value":"singleline comment"},{"kind":"eof"}]') { throw result }
1123
- // },
1124
- // () => {
1125
- // const result = tokenizeString('true//singleline comment\nfalse')
1126
- // if (result !== '[{"kind":"true"},{"kind":"//","value":"singleline comment"},{"kind":"nl"},{"kind":"false"},{"kind":"eof"}]') { throw result }
1127
- // },
1128
- // () => {
1129
- // const result = tokenizeString('/* multiline comment */')
1130
- // if (result !== '[{"kind":"/*","value":" multiline comment "},{"kind":"eof"}]') { throw result }
1131
- // },
1132
- // () => {
1133
- // const result = tokenizeString('/* multiline comment *')
1134
- // if (result !== 'error') { throw result }
1135
- // },
1136
- // () => {
1137
- // const result = tokenizeString('/* multiline comment ')
1138
- // if (result !== 'error') { throw result }
1139
- // },
1140
- // () => {
1141
- // const result = tokenizeString('/* multiline comment \n * **/')
1142
- // if (result !== '[{"kind":"/*","value":" multiline comment \\n * *"},{"kind":"nl"},{"kind":"eof"}]') { throw result }
1143
- // },
1144
- // () => {
1145
- // const result = tokenizeString('/* multiline comment *\n * **/')
1146
- // if (result !== '[{"kind":"/*","value":" multiline comment *\\n * *"},{"kind":"nl"},{"kind":"eof"}]') { throw result }
1147
- // },
1148
- // ],
979
+ comments: [
980
+ () => {
981
+ const result = tokenizeString('//singleline comment');
982
+ if (result !== '[{"kind":"//","value":"singleline comment"},{"kind":"eof"}]') {
983
+ throw result;
984
+ }
985
+ },
986
+ () => {
987
+ const result = tokenizeString('true//singleline comment\nfalse');
988
+ if (result !== '[{"kind":"true"},{"kind":"//","value":"singleline comment"},{"kind":"nl"},{"kind":"false"},{"kind":"eof"}]') {
989
+ throw result;
990
+ }
991
+ },
992
+ () => {
993
+ const result = tokenizeString('/* multiline comment */');
994
+ if (result !== '[{"kind":"/*","value":" multiline comment "},{"kind":"eof"}]') {
995
+ throw result;
996
+ }
997
+ },
998
+ () => {
999
+ const result = tokenizeString('/* multiline comment *');
1000
+ assertEq(result, 'error');
1001
+ },
1002
+ () => {
1003
+ const result = tokenizeString('/* multiline comment ');
1004
+ assertEq(result, 'error');
1005
+ },
1006
+ () => {
1007
+ const result = tokenizeString('/* multiline comment \n * **/');
1008
+ if (result !== '[{"kind":"/*","value":" multiline comment \\n * *"},{"kind":"nl"},{"kind":"eof"}]') {
1009
+ throw result;
1010
+ }
1011
+ },
1012
+ () => {
1013
+ const result = tokenizeString('/* multiline comment *\n * **/');
1014
+ if (result !== '[{"kind":"/*","value":" multiline comment *\\n * *"},{"kind":"nl"},{"kind":"eof"}]') {
1015
+ throw result;
1016
+ }
1017
+ },
1018
+ ],
1019
+ metadata: [
1020
+ () => {
1021
+ const result = toArray(tokenizeJs(stringToList(''))('a.js'));
1022
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":1}}]');
1023
+ },
1024
+ () => {
1025
+ const result = toArray(tokenizeJs(stringToList('true'))('a.js'));
1026
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"true"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":5}}]');
1027
+ },
1028
+ () => {
1029
+ const result = toArray(tokenizeJs(stringToList('true false'))('a.js'));
1030
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"true"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"ws"},"metadata":{"path":"a.js","line":1,"column":5}},{"token":{"kind":"false"},"metadata":{"path":"a.js","line":1,"column":6}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":11}}]');
1031
+ },
1032
+ () => {
1033
+ // a lone \n collapses into a single nl token, but line/column still advance
1034
+ // correctly for whatever comes after it
1035
+ const result = toArray(tokenizeJs(stringToList('a\nb'))('a.js'));
1036
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"id","value":"a"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":2}},{"token":{"kind":"id","value":"b"},"metadata":{"path":"a.js","line":2,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":2,"column":2}}]');
1037
+ },
1038
+ () => {
1039
+ // two consecutive newlines still collapse into one nl token, but line still
1040
+ // advances by two for the token after them
1041
+ const result = toArray(tokenizeJs(stringToList('a\n\nb'))('a.js'));
1042
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"id","value":"a"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":2}},{"token":{"kind":"id","value":"b"},"metadata":{"path":"a.js","line":3,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":3,"column":2}}]');
1043
+ },
1044
+ () => {
1045
+ // position after a multi-line block comment resumes on the comment's closing line
1046
+ const result = toArray(tokenizeJs(stringToList('/* c\n */ x'))('a.js'));
1047
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"/*","value":" c\\n "},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"ws"},"metadata":{"path":"a.js","line":2,"column":4}},{"token":{"kind":"id","value":"x"},"metadata":{"path":"a.js","line":2,"column":5}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":2,"column":6}}]');
1048
+ },
1049
+ () => {
1050
+ const result = toArray(tokenizeJs(stringToList('"unterminated'))('a.js'));
1051
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"error","message":"invalid token"},"metadata":{"path":"a.js","line":1,"column":1}}]');
1052
+ },
1053
+ () => {
1054
+ // position points at the poisoning trailing char ('0'), not the start of input
1055
+ const result = toArray(tokenizeJs(stringToList('00'))('a.js'));
1056
+ assertEq(JSON.stringify(result), '[{"token":{"kind":"error","message":"invalid token"},"metadata":{"path":"a.js","line":1,"column":2}}]');
1057
+ },
1058
+ ],
1059
+ // DJS-level: keyword remapping and '-'-folding on top of tokenizeJs. Doesn't re-test
1060
+ // JS-level token shapes already covered above/elsewhere in this file.
1061
+ djsTokenize: [
1062
+ () => {
1063
+ // keywords other than true/false/null/undefined become plain ids
1064
+ const result = toArray(tokenize(stringToList('break'))(''));
1065
+ assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"id","value":"break"}},{"metadata":{"column":6,"line":1,"path":""},"token":{"kind":"eof"}}]');
1066
+ },
1067
+ () => {
1068
+ const result = toArray(tokenize(stringToList('-10'))(''));
1069
+ assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"bf":[-10n,0],"kind":"number","value":"-10"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"eof"}}]');
1070
+ },
1071
+ () => {
1072
+ const result = toArray(tokenize(stringToList('-0'))(''));
1073
+ assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"bf":[0n,0],"kind":"number","value":"-0"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]');
1074
+ },
1075
+ () => {
1076
+ const result = toArray(tokenize(stringToList('-1234567890n'))(''));
1077
+ assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"bigint","value":-1234567890n}},{"metadata":{"column":13,"line":1,"path":""},"token":{"kind":"eof"}}]');
1078
+ },
1079
+ () => {
1080
+ // '-' followed by '-': one error, stays in minus-state waiting for what follows
1081
+ const result = toArray(tokenize(stringToList('--'))(''));
1082
+ assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]');
1083
+ },
1084
+ () => {
1085
+ const result = toArray(tokenize(stringToList('---'))(''));
1086
+ assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"eof"}}]');
1087
+ },
1088
+ () => {
1089
+ // dangling '-' at eof
1090
+ const result = toArray(tokenize(stringToList('-'))(''));
1091
+ assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"eof"}}]');
1092
+ },
1093
+ () => {
1094
+ const result = toArray(tokenize(stringToList('[-1234567890n]'))(''));
1095
+ assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"["}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"bigint","value":-1234567890n}},{"metadata":{"column":14,"line":1,"path":""},"token":{"kind":"]"}},{"metadata":{"column":15,"line":1,"path":""},"token":{"kind":"eof"}}]');
1096
+ },
1097
+ () => {
1098
+ // grammar-level tokenizer error position flows through the DJS wrapper unchanged
1099
+ const result = toArray(tokenize(stringToList('00'))(''));
1100
+ assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}}]');
1101
+ },
1102
+ ],
1103
+ // Regression coverage for large inputs: both a file with many short tokens and a
1104
+ // single very long token used to overflow the JS call stack, because fjs/bnf/descent's
1105
+ // matcher recursed once per grammar step. It now runs on an explicit frame stack, so
1106
+ // the whole-file jsGrammar() match is safe at any input length.
1107
+ largeInputs: [
1108
+ () => {
1109
+ // many short whitespace tokens: the reported repro (`' '.repeat(5000)`)
1110
+ const result = tokenizeString(' '.repeat(5000));
1111
+ assertEq(result, '[{"kind":"ws"},{"kind":"eof"}]');
1112
+ },
1113
+ () => {
1114
+ // many distinct short tokens, well past the ~1000-1500 token crash threshold
1115
+ // the old whole-file recursive match hit for this shape
1116
+ const src = Array.from({ length: 3000 }, (_, i) => `a${i % 10}`).join(' ');
1117
+ const result = tokenizeString(src);
1118
+ assert(result !== 'error', result);
1119
+ const parsed = JSON.parse(result);
1120
+ // 3000 ids + 2999 separating ws + a trailing eof token
1121
+ assertEq(parsed.length, 3000 + 2999 + 1);
1122
+ },
1123
+ () => {
1124
+ // same many-short-tokens shape through the metadata-aware entry point
1125
+ const src = 'x '.repeat(3000);
1126
+ const result = toArray(tokenizeJs(stringToList(src))('a.js'));
1127
+ assertEq(result.length, 3000 * 2 + 1);
1128
+ },
1129
+ () => {
1130
+ // a single long token: a 5 KB string literal — overflows unless the descent
1131
+ // matcher itself is iterative
1132
+ const value = 'a'.repeat(5000);
1133
+ const result = tokenizeString(`"${value}"`);
1134
+ assertEq(result, `[{"kind":"string","value":"${value}"},{"kind":"eof"}]`);
1135
+ },
1136
+ () => {
1137
+ // a single long token via the hand-written recursive multilineContent rule:
1138
+ // a 20 KB block comment (the size the pre-grammar tokenizer handled)
1139
+ const value = 'x'.repeat(20000);
1140
+ const result = tokenizeString(`/*${value}*/`);
1141
+ assertEq(result, `[{"kind":"/*","value":"${value}"},{"kind":"eof"}]`);
1142
+ },
1143
+ () => {
1144
+ // a single long identifier (repeat0Plus(idChar) inside one token match)
1145
+ const value = 'x'.repeat(10000);
1146
+ const result = tokenizeString(value);
1147
+ assertEq(result, `[{"kind":"id","value":"${value}"},{"kind":"eof"}]`);
1148
+ },
1149
+ ],
1149
1150
  };