@shd101wyy/yo 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -0
- package/README.md +80 -0
- package/out/cjs/index.cjs +51 -0
- package/out/cjs/yo-cli.cjs +2158 -0
- package/out/esm/index.mjs +51 -0
- package/out/types/src/codegen/async/runtime.d.ts +2 -0
- package/out/types/src/codegen/async/state-code-gen.d.ts +10 -0
- package/out/types/src/codegen/async/state-machine.d.ts +13 -0
- package/out/types/src/codegen/c/collection.d.ts +3 -0
- package/out/types/src/codegen/codegen-c.d.ts +12 -0
- package/out/types/src/codegen/constants.d.ts +3 -0
- package/out/types/src/codegen/expressions/array.d.ts +4 -0
- package/out/types/src/codegen/expressions/generation.d.ts +11 -0
- package/out/types/src/codegen/expressions/index.d.ts +2 -0
- package/out/types/src/codegen/functions/collection.d.ts +5 -0
- package/out/types/src/codegen/functions/context.d.ts +57 -0
- package/out/types/src/codegen/functions/generation.d.ts +25 -0
- package/out/types/src/codegen/functions/index.d.ts +2 -0
- package/out/types/src/codegen/index.d.ts +20 -0
- package/out/types/src/codegen/parallelism/runtime.d.ts +2 -0
- package/out/types/src/codegen/types/collection.d.ts +8 -0
- package/out/types/src/codegen/types/generation.d.ts +13 -0
- package/out/types/src/codegen/types/index.d.ts +2 -0
- package/out/types/src/codegen/utils/fixup.d.ts +2 -0
- package/out/types/src/codegen/utils/index.d.ts +77 -0
- package/out/types/src/codegen/values/index.d.ts +1 -0
- package/out/types/src/emitter.d.ts +11 -0
- package/out/types/src/env.d.ts +85 -0
- package/out/types/src/error.d.ts +45 -0
- package/out/types/src/evaluator/async/await-analysis-types.d.ts +23 -0
- package/out/types/src/evaluator/async/await-analysis.d.ts +5 -0
- package/out/types/src/evaluator/builtins/alignof.d.ts +8 -0
- package/out/types/src/evaluator/builtins/and_or.d.ts +8 -0
- package/out/types/src/evaluator/builtins/arc_fns.d.ts +58 -0
- package/out/types/src/evaluator/builtins/array_fns.d.ts +0 -0
- package/out/types/src/evaluator/builtins/as.d.ts +8 -0
- package/out/types/src/evaluator/builtins/async_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_assert.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_boolean_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_expect_error.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_list_fns.d.ts +33 -0
- package/out/types/src/evaluator/builtins/compt_print.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_string_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/consume.d.ts +8 -0
- package/out/types/src/evaluator/builtins/drop.d.ts +8 -0
- package/out/types/src/evaluator/builtins/dup.d.ts +8 -0
- package/out/types/src/evaluator/builtins/expr_fns.d.ts +33 -0
- package/out/types/src/evaluator/builtins/future_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/gc.d.ts +8 -0
- package/out/types/src/evaluator/builtins/gensym.d.ts +8 -0
- package/out/types/src/evaluator/builtins/impl_constraint.d.ts +8 -0
- package/out/types/src/evaluator/builtins/macro_expand.d.ts +8 -0
- package/out/types/src/evaluator/builtins/numeric_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/panic.d.ts +8 -0
- package/out/types/src/evaluator/builtins/ptr_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/quote.d.ts +13 -0
- package/out/types/src/evaluator/builtins/rc.d.ts +8 -0
- package/out/types/src/evaluator/builtins/sizeof.d.ts +8 -0
- package/out/types/src/evaluator/builtins/the.d.ts +8 -0
- package/out/types/src/evaluator/builtins/type_fns.d.ts +28 -0
- package/out/types/src/evaluator/builtins/va_start.d.ts +8 -0
- package/out/types/src/evaluator/builtins/var_fns.d.ts +18 -0
- package/out/types/src/evaluator/calls/array.d.ts +13 -0
- package/out/types/src/evaluator/calls/array_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/closure_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/compt_function.d.ts +19 -0
- package/out/types/src/evaluator/calls/compt_list_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/function.d.ts +16 -0
- package/out/types/src/evaluator/calls/function_type.d.ts +15 -0
- package/out/types/src/evaluator/calls/helper.d.ts +42 -0
- package/out/types/src/evaluator/calls/iso.d.ts +15 -0
- package/out/types/src/evaluator/calls/module_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/numeric_type.d.ts +15 -0
- package/out/types/src/evaluator/calls/pointer.d.ts +8 -0
- package/out/types/src/evaluator/calls/pointer_type.d.ts +14 -0
- package/out/types/src/evaluator/calls/type.d.ts +12 -0
- package/out/types/src/evaluator/context.d.ts +169 -0
- package/out/types/src/evaluator/exprs/_expr.d.ts +8 -0
- package/out/types/src/evaluator/exprs/assignment.d.ts +9 -0
- package/out/types/src/evaluator/exprs/begin.d.ts +10 -0
- package/out/types/src/evaluator/exprs/binding.d.ts +12 -0
- package/out/types/src/evaluator/exprs/c_include.d.ts +8 -0
- package/out/types/src/evaluator/exprs/cond.d.ts +8 -0
- package/out/types/src/evaluator/exprs/destructuring_assignment.d.ts +33 -0
- package/out/types/src/evaluator/exprs/exists.d.ts +0 -0
- package/out/types/src/evaluator/exprs/expr.d.ts +9 -0
- package/out/types/src/evaluator/exprs/extern.d.ts +8 -0
- package/out/types/src/evaluator/exprs/identifer_and_operator.d.ts +9 -0
- package/out/types/src/evaluator/exprs/import.d.ts +9 -0
- package/out/types/src/evaluator/exprs/initialization_assignment.d.ts +8 -0
- package/out/types/src/evaluator/exprs/match.d.ts +8 -0
- package/out/types/src/evaluator/exprs/open.d.ts +8 -0
- package/out/types/src/evaluator/exprs/property_access.d.ts +8 -0
- package/out/types/src/evaluator/exprs/recur.d.ts +8 -0
- package/out/types/src/evaluator/exprs/subtype_of.d.ts +21 -0
- package/out/types/src/evaluator/exprs/test.d.ts +8 -0
- package/out/types/src/evaluator/exprs/typeof.d.ts +8 -0
- package/out/types/src/evaluator/exprs/while.d.ts +8 -0
- package/out/types/src/evaluator/index.d.ts +26 -0
- package/out/types/src/evaluator/types/array.d.ts +8 -0
- package/out/types/src/evaluator/types/closure.d.ts +8 -0
- package/out/types/src/evaluator/types/compt_list.d.ts +8 -0
- package/out/types/src/evaluator/types/concrete_module.d.ts +8 -0
- package/out/types/src/evaluator/types/dyn.d.ts +8 -0
- package/out/types/src/evaluator/types/enum.d.ts +8 -0
- package/out/types/src/evaluator/types/expr_synthesizer.d.ts +14 -0
- package/out/types/src/evaluator/types/field.d.ts +14 -0
- package/out/types/src/evaluator/types/fn_module.d.ts +8 -0
- package/out/types/src/evaluator/types/function.d.ts +58 -0
- package/out/types/src/evaluator/types/future_module.d.ts +8 -0
- package/out/types/src/evaluator/types/module.d.ts +19 -0
- package/out/types/src/evaluator/types/newtype.d.ts +8 -0
- package/out/types/src/evaluator/types/object.d.ts +8 -0
- package/out/types/src/evaluator/types/proofs.d.ts +0 -0
- package/out/types/src/evaluator/types/slice.d.ts +8 -0
- package/out/types/src/evaluator/types/struct.d.ts +8 -0
- package/out/types/src/evaluator/types/synthesizer.d.ts +16 -0
- package/out/types/src/evaluator/types/tuple.d.ts +18 -0
- package/out/types/src/evaluator/types/union.d.ts +8 -0
- package/out/types/src/evaluator/types/utils.d.ts +71 -0
- package/out/types/src/evaluator/types/validation.d.ts +3 -0
- package/out/types/src/evaluator/utils/array-utils.d.ts +15 -0
- package/out/types/src/evaluator/utils/closure.d.ts +35 -0
- package/out/types/src/evaluator/utils.d.ts +4 -0
- package/out/types/src/evaluator/values/anonymous_function.d.ts +8 -0
- package/out/types/src/evaluator/values/anonymous_module.d.ts +17 -0
- package/out/types/src/evaluator/values/anonymous_struct.d.ts +8 -0
- package/out/types/src/evaluator/values/array.d.ts +8 -0
- package/out/types/src/evaluator/values/boolean.d.ts +3 -0
- package/out/types/src/evaluator/values/char.d.ts +3 -0
- package/out/types/src/evaluator/values/compt_list.d.ts +8 -0
- package/out/types/src/evaluator/values/dyn.d.ts +8 -0
- package/out/types/src/evaluator/values/float.d.ts +4 -0
- package/out/types/src/evaluator/values/integer.d.ts +4 -0
- package/out/types/src/evaluator/values/module.d.ts +58 -0
- package/out/types/src/evaluator/values/string.d.ts +3 -0
- package/out/types/src/evaluator/values/tuple.d.ts +32 -0
- package/out/types/src/expr.d.ts +456 -0
- package/out/types/src/function-value.d.ts +42 -0
- package/out/types/src/index.d.ts +4 -0
- package/out/types/src/lexer.d.ts +2 -0
- package/out/types/src/logger.d.ts +1 -0
- package/out/types/src/module-manager.d.ts +30 -0
- package/out/types/src/naming-checker.d.ts +4 -0
- package/out/types/src/parser.d.ts +33 -0
- package/out/types/src/test-runner.d.ts +30 -0
- package/out/types/src/tests/codegen.test.d.ts +1 -0
- package/out/types/src/tests/fixme.test.d.ts +1 -0
- package/out/types/src/tests/module-manager.test.d.ts +1 -0
- package/out/types/src/tests/parser.test.d.ts +1 -0
- package/out/types/src/tests/sample.test.d.ts +0 -0
- package/out/types/src/tests/std.test.d.ts +1 -0
- package/out/types/src/token.d.ts +40 -0
- package/out/types/src/type-value.d.ts +7 -0
- package/out/types/src/types/compatibility.d.ts +16 -0
- package/out/types/src/types/creators.d.ts +73 -0
- package/out/types/src/types/definitions.d.ts +218 -0
- package/out/types/src/types/guards.d.ts +70 -0
- package/out/types/src/types/hierarchy.d.ts +4 -0
- package/out/types/src/types/index.d.ts +7 -0
- package/out/types/src/types/module_field.d.ts +2 -0
- package/out/types/src/types/tags.d.ts +45 -0
- package/out/types/src/types/utils.d.ts +50 -0
- package/out/types/src/unit-value.d.ts +7 -0
- package/out/types/src/utils.d.ts +6 -0
- package/out/types/src/value-tag.d.ts +29 -0
- package/out/types/src/value.d.ts +110 -0
- package/out/types/src/yo-cli.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +57 -0
- package/scripts/check-liburing.js +76 -0
- package/std/alg/hash.yo +50 -0
- package/std/allocator.yo +113 -0
- package/std/allocators/c_allocator.yo +118 -0
- package/std/async.yo +13 -0
- package/std/collections/array_list.yo +415 -0
- package/std/collections/hash_map.yo +482 -0
- package/std/collections/hash_set.yo +706 -0
- package/std/collections/index.yo +11 -0
- package/std/collections/linked_list.yo +439 -0
- package/std/error.yo +0 -0
- package/std/gc.yo +10 -0
- package/std/index.yo +12 -0
- package/std/io/file.yo +191 -0
- package/std/io/index.yo +5 -0
- package/std/libc/assert.yo +39 -0
- package/std/libc/ctype.yo +57 -0
- package/std/libc/errno.yo +182 -0
- package/std/libc/float.yo +87 -0
- package/std/libc/index.yo +29 -0
- package/std/libc/limits.yo +65 -0
- package/std/libc/math.yo +679 -0
- package/std/libc/signal.yo +101 -0
- package/std/libc/stdatomic.yo +213 -0
- package/std/libc/stdint.yo +214 -0
- package/std/libc/stdio.yo +225 -0
- package/std/libc/stdlib.yo +204 -0
- package/std/libc/string.yo +151 -0
- package/std/libc/time.yo +92 -0
- package/std/libc/unistd.yo +130 -0
- package/std/monad.yo +152 -0
- package/std/prelude.yo +3094 -0
- package/std/string/index.yo +8 -0
- package/std/string/rune.yo +82 -0
- package/std/string/string.yo +288 -0
- package/std/sync.yo +95 -0
- package/std/thread.yo +36 -0
- package/std/time.yo +13 -0
- package/std/worker.yo +36 -0
- package/vendor/mimalloc/.gitattributes +12 -0
- package/vendor/mimalloc/CMakeLists.txt +763 -0
- package/vendor/mimalloc/LICENSE +21 -0
- package/vendor/mimalloc/SECURITY.md +41 -0
- package/vendor/mimalloc/azure-pipelines.yml +251 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect32.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect32.lib +0 -0
- package/vendor/mimalloc/bin/minject-arm64.exe +0 -0
- package/vendor/mimalloc/bin/minject.exe +0 -0
- package/vendor/mimalloc/bin/minject32.exe +0 -0
- package/vendor/mimalloc/bin/readme.md +118 -0
- package/vendor/mimalloc/cmake/JoinPaths.cmake +23 -0
- package/vendor/mimalloc/cmake/mimalloc-config-version.cmake +19 -0
- package/vendor/mimalloc/cmake/mimalloc-config.cmake +14 -0
- package/vendor/mimalloc/contrib/docker/alpine/Dockerfile +23 -0
- package/vendor/mimalloc/contrib/docker/alpine-arm32v7/Dockerfile +28 -0
- package/vendor/mimalloc/contrib/docker/alpine-x86/Dockerfile +28 -0
- package/vendor/mimalloc/contrib/docker/manylinux-x64/Dockerfile +23 -0
- package/vendor/mimalloc/contrib/docker/readme.md +10 -0
- package/vendor/mimalloc/contrib/vcpkg/portfile.cmake +64 -0
- package/vendor/mimalloc/contrib/vcpkg/readme.md +40 -0
- package/vendor/mimalloc/contrib/vcpkg/usage +20 -0
- package/vendor/mimalloc/contrib/vcpkg/vcpkg-cmake-wrapper.cmake +20 -0
- package/vendor/mimalloc/contrib/vcpkg/vcpkg.json +48 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-a.svg +887 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-b.svg +1185 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-a.svg +757 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-b.svg +1028 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-1.svg +769 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-a.svg +868 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-b.svg +1157 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-2.svg +983 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-1.svg +683 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-2.svg +854 -0
- package/vendor/mimalloc/doc/bench-2020/bench-spec-rss.svg +713 -0
- package/vendor/mimalloc/doc/bench-2020/bench-spec.svg +713 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-1.svg +890 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-2.svg +1146 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-1.svg +796 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-2.svg +974 -0
- package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-a.svg +952 -0
- package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-b.svg +1255 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-a.svg +955 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-b.svg +1269 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-a.svg +836 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-b.svg +1131 -0
- package/vendor/mimalloc/doc/bench-2021/bench-macmini-2021-01-30.svg +766 -0
- package/vendor/mimalloc/doc/doxyfile +2895 -0
- package/vendor/mimalloc/doc/ds-logo.jpg +0 -0
- package/vendor/mimalloc/doc/ds-logo.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-doc.h +1452 -0
- package/vendor/mimalloc/doc/mimalloc-doxygen.css +60 -0
- package/vendor/mimalloc/doc/mimalloc-logo-100.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-logo.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-logo.svg +161 -0
- package/vendor/mimalloc/doc/spades-logo.png +0 -0
- package/vendor/mimalloc/doc/unreal-logo.svg +43 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj +500 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj.filters +108 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj +508 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj.filters +111 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-test-dep.vcxproj +355 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-test.vcxproj +360 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test-api.vcxproj +295 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test-stress.vcxproj +292 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test.vcxproj +289 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc.sln +151 -0
- package/vendor/mimalloc/include/mimalloc/atomic.h +557 -0
- package/vendor/mimalloc/include/mimalloc/internal.h +1153 -0
- package/vendor/mimalloc/include/mimalloc/prim.h +421 -0
- package/vendor/mimalloc/include/mimalloc/track.h +145 -0
- package/vendor/mimalloc/include/mimalloc/types.h +685 -0
- package/vendor/mimalloc/include/mimalloc-new-delete.h +66 -0
- package/vendor/mimalloc/include/mimalloc-override.h +68 -0
- package/vendor/mimalloc/include/mimalloc-stats.h +103 -0
- package/vendor/mimalloc/include/mimalloc.h +612 -0
- package/vendor/mimalloc/mimalloc.pc.in +11 -0
- package/vendor/mimalloc/readme.md +946 -0
- package/vendor/mimalloc/src/alloc-aligned.c +360 -0
- package/vendor/mimalloc/src/alloc-override.c +316 -0
- package/vendor/mimalloc/src/alloc-posix.c +185 -0
- package/vendor/mimalloc/src/alloc.c +692 -0
- package/vendor/mimalloc/src/arena-abandon.c +346 -0
- package/vendor/mimalloc/src/arena.c +1043 -0
- package/vendor/mimalloc/src/bitmap.c +441 -0
- package/vendor/mimalloc/src/bitmap.h +119 -0
- package/vendor/mimalloc/src/free.c +572 -0
- package/vendor/mimalloc/src/heap.c +733 -0
- package/vendor/mimalloc/src/init.c +714 -0
- package/vendor/mimalloc/src/libc.c +334 -0
- package/vendor/mimalloc/src/options.c +663 -0
- package/vendor/mimalloc/src/os.c +770 -0
- package/vendor/mimalloc/src/page-queue.c +390 -0
- package/vendor/mimalloc/src/page.c +1049 -0
- package/vendor/mimalloc/src/prim/emscripten/prim.c +249 -0
- package/vendor/mimalloc/src/prim/osx/alloc-override-zone.c +461 -0
- package/vendor/mimalloc/src/prim/osx/prim.c +9 -0
- package/vendor/mimalloc/src/prim/prim.c +76 -0
- package/vendor/mimalloc/src/prim/readme.md +9 -0
- package/vendor/mimalloc/src/prim/unix/prim.c +934 -0
- package/vendor/mimalloc/src/prim/wasi/prim.c +284 -0
- package/vendor/mimalloc/src/prim/windows/etw-mimalloc.wprp +61 -0
- package/vendor/mimalloc/src/prim/windows/etw.h +905 -0
- package/vendor/mimalloc/src/prim/windows/etw.man +0 -0
- package/vendor/mimalloc/src/prim/windows/prim.c +878 -0
- package/vendor/mimalloc/src/prim/windows/readme.md +17 -0
- package/vendor/mimalloc/src/random.c +258 -0
- package/vendor/mimalloc/src/segment-map.c +142 -0
- package/vendor/mimalloc/src/segment.c +1702 -0
- package/vendor/mimalloc/src/static.c +41 -0
- package/vendor/mimalloc/src/stats.c +635 -0
- package/vendor/mimalloc/test/CMakeLists.txt +56 -0
- package/vendor/mimalloc/test/main-override-dep.cpp +51 -0
- package/vendor/mimalloc/test/main-override-dep.h +11 -0
- package/vendor/mimalloc/test/main-override-static.c +539 -0
- package/vendor/mimalloc/test/main-override.c +36 -0
- package/vendor/mimalloc/test/main-override.cpp +497 -0
- package/vendor/mimalloc/test/main.c +46 -0
- package/vendor/mimalloc/test/readme.md +16 -0
- package/vendor/mimalloc/test/test-api-fill.c +343 -0
- package/vendor/mimalloc/test/test-api.c +466 -0
- package/vendor/mimalloc/test/test-stress.c +428 -0
- package/vendor/mimalloc/test/test-wrong.c +92 -0
- package/vendor/mimalloc/test/testhelper.h +49 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
University of Illinois/NCSA
|
|
2
|
+
Open Source License
|
|
3
|
+
|
|
4
|
+
```
|
|
5
|
+
Copyright (c) 2023 ~ 2025 Yiyi Wang
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
Developed by: Yiyi Wang
|
|
9
|
+
https://github.com/0xgg/Yo
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
|
|
15
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution.
|
|
16
|
+
Neither the names of Yiyi Wang, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Yo
|
|
2
|
+
|
|
3
|
+
`Work in Progress`
|
|
4
|
+
|
|
5
|
+
A multi-paradigm, general-purpose, compiled programming language.
|
|
6
|
+
Yo aims to be **Simple** and **Fast** (around 0% - 15% slower than C).
|
|
7
|
+
|
|
8
|
+
> The name `Yo` comes from the Chinese word `柚` (yòu), meaning `pomelo`, a large citrus fruit similar to grapefruit. It's my daughter's nickname.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- First-class types.
|
|
13
|
+
- Compile-time evaluation.
|
|
14
|
+
- Homoiconicity and metaprogramming (**Yo** is just a combination of **Lisp** and **C**).
|
|
15
|
+
- Closure.
|
|
16
|
+
- [Async/await](./ASYNC_AWAIT.md) (Stackless coroutine & Cooperative multi-tasking).
|
|
17
|
+
- `object` type with [Non-atomic Reference Counting and Thread-Local Cycle Collection](./CYCLE_COLLECTION.md).
|
|
18
|
+
- [Compile-time Reference Counting with Ownership and Lifetime Analysis](./COMPILE_TIME_RC_WITH_OWNERSHIP_ANALYSIS.md).
|
|
19
|
+
- Thread-per-core parallelism model (see [PARALLEL.md](./PARALLEL.md)).
|
|
20
|
+
- **C** interop.
|
|
21
|
+
- etc
|
|
22
|
+
|
|
23
|
+
## Language Design
|
|
24
|
+
|
|
25
|
+
For design of the language, please refer to the [DESIGN.md](./DESIGN.md).
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
The `Yo` language is currently distributed as an `npm` package:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ npm install -g @shd101wyy/yo # Install yo compiler globally
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
It exposes the `yo` command in your terminal.
|
|
36
|
+
There is also an alias `yo-cli` for `yo` command in case of naming conflicts.
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
The `Yo` compiler is written in [TypeScript](https://www.typescriptlang.org/) and uses [Bun](https://bun.sh/) as the runtime.
|
|
41
|
+
|
|
42
|
+
Please install [nix](https://nixos.org/download.html) and [direnv](https://direnv.net/) before proceeding.
|
|
43
|
+
|
|
44
|
+
The dev environment is defined in [shell.nix](./shell.nix). You can also manually install the dependencies listed in the file.
|
|
45
|
+
|
|
46
|
+
### Setup
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
$ cd Yo
|
|
50
|
+
$ direnv allow . # Run this command to activate the nix shell.
|
|
51
|
+
# You only need to run it once.
|
|
52
|
+
$ bun install # Install necessary dependencies.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run the following command to watch for changes and build the project:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
$ bun run dev
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Run the following command to build the project:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
$ bun run build
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Test some local yo-cli:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ bun run src/yo-cli.ts compile src/tests/examples/fixme.yo
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Editor support
|
|
74
|
+
|
|
75
|
+
- Vim / Neovim: a minimal syntax file and a usage README are available in `vscode-extension/syntaxes/`.
|
|
76
|
+
See [vscode-extension/syntaxes/README.md](./vscode-extension/syntaxes/README.md) for installation steps, `ftdetect` examples and `home-manager` snippets.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
[UIUC/NCSA Open Source License](./LICENSE.md)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var Je=Object.create;var W=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var rt=(e,n)=>{for(var t in n)W(e,t,{get:n[t],enumerable:!0})},Se=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of et(n))!nt.call(e,i)&&i!==t&&W(e,i,{get:()=>n[i],enumerable:!(o=Xe(n,i))||o.enumerable});return e};var ot=(e,n,t)=>(t=e!=null?Je(tt(e)):{},Se(n||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e)),it=e=>Se(W({},"__esModule",{value:!0}),e);var Ut={};rt(Ut,{IdentifierRegex:()=>O,Operators:()=>K,PlaceholderToken:()=>B,RAIIToken:()=>at,TokenType:()=>M,charIsOperator:()=>w,clearAllGlobalImplState:()=>He,clearGenericImplsFromModule:()=>We,clearImplsFromModule:()=>Ke,findMatchingBracketTokenIndex:()=>ce,generateExprFromCode:()=>Z,stringIsOperator:()=>pe,tokenize:()=>fe});module.exports=it(Ut);var It=require("node:fs"),At=ot(require("path"));var C=class{constructor({characterIndex:n,message:t}){this.characterIndex=n,this.message=t}},H=class{constructor(n,t){this.tokenAndErrorList=[];this.tokenAndErrorList=n,this.isAssertionError=t||!1}toString(){return this.tokenAndErrorList.map(({token:t,errorMessage:o})=>`Error: ${o}
|
|
2
|
+
${Me({token:t})}`).join(`
|
|
3
|
+
|
|
4
|
+
`)}};function Me({token:e}){let{position:n,modulePath:t,inputString:o}=e,{row:i,column:r}=n,s=o.split(`
|
|
5
|
+
`)[i];return`${t}:${i+1}:${r+1}:
|
|
6
|
+
${s}
|
|
7
|
+
${" ".repeat(r+Math.floor(e.value.length/2))}^`}function y({token:e,errorMessage:n,cause:t,isAssertionError:o}){let i=`${n.trim()}
|
|
8
|
+
|
|
9
|
+
${Me({token:e})}`;return new H([{token:e,errorMessage:i+(t!=null&&t.message?`
|
|
10
|
+
`+t.message:"")}],o)}var M=(m=>(m.Operator="operator",m.Dot=".",m.LParen="(",m.RParen=")",m.LBracket="[",m.RBracket="]",m.LCurlyBracket="{",m.RCurlyBracket="}",m.Char="char",m.String="string",m.Identifier="identifier",m.Integer="integer",m.Float="float",m.Bool="bool",m.Semicolon=";",m.Comma=",",m.SingleLineComment="single_line_comment",m.MultiLineComment="multi_line_comment",m.Whitespace="whitespace",m.BacktickIdentifier="backtick_identifier",m))(M||{}),B={modulePath:"_",inputString:"_",type:"identifier",value:"_",position:{row:0,column:0,character:0}},at={modulePath:"drop",inputString:"drop",type:"identifier",value:"drop",position:{row:0,column:0,character:0}},K=["=","+","-","*","/","<",">","@","$","~","&","%","|","!","?","^",".",":","\\","#"];function w(e){return K.includes(e)}function pe(e){let n=!0;for(let t=0;t<e.length;t++){let o=e[t];if(!w(o)){n=!1;break}}return n}var O=/^[_a-zA-Z\xA0-\uFFFF][_a-zA-Z0-9\xA0-\uFFFF]*[!?]?$/;function ce(e,n){let t=")";if(!e[n])return-1;let o=e[n].type;if(o==="{")t="}";else if(o==="(")t=")";else if(o==="[")t="]";else throw this.formatErrorMessage(e[n],"Expected '{', '(' or '['");n=n+1;let i=1,r=-1;for(;;){let p=e[n];if(!p)return-1;if(p.type===t){if(i=i-1,i===0){r=n;break}}else p.type===o&&(i=i+1);n=n+1}return r}function fe(e,n){let t=[],o=0,i=0;for(let r=0;r<e.length;r++){let p=e[r],s=r-i,u=r,f="",c=r;if(e[c]===".")for(;e[c]===".";)f+=e[c],c=c+1;else for(;w(e[c])&&e[c]!==".";)f+=e[c],c=c+1;if(f&&!f.startsWith("//")&&!f.startsWith("/*")){t.push({type:f==="."?".":"operator",value:f,position:{row:o,column:s,character:u},modulePath:n,inputString:e}),r=c-1;continue}switch(p){case" ":case" ":case`
|
|
11
|
+
`:case"\r":{let l="",a=r,g=o;for(;e[a]===" "||e[a]===" "||e[a]===`
|
|
12
|
+
`||e[a]==="\r";)l+=e[a],e[a]===`
|
|
13
|
+
`&&(o++,i=a+1),a=a+1;t.push({type:"whitespace",value:l,position:{row:g,column:s,character:u},modulePath:n,inputString:e}),r=a-1;break}case"/":if(e[r+1]==="/"){let l="",a=r;for(;e[a]!==`
|
|
14
|
+
`&&a<e.length;)l+=e[a],a=a+1;t.push({type:"single_line_comment",value:l,position:{row:o,column:s,character:u},modulePath:n,inputString:e}),r=a-1}else if(e[r+1]==="*"){let l=r,a="",g=o,d=1;for(a+=e[l],l++,a+=e[l],l++;d>0&&l<e.length;){if(e[l]===`
|
|
15
|
+
`&&(i=l+1,o++),e[l]==="/"&&e[l+1]==="*"){d++,a+="/*",l+=2;continue}if(e[l]==="*"&&e[l+1]==="/"){d--,a+="*/",l+=2;continue}a+=e[l],l++}if(d>0)throw new C({message:"Unterminated multi-line comment",characterIndex:e.length-1});t.push({type:"multi_line_comment",value:a,position:{row:g,column:s,character:u},modulePath:n,inputString:e}),r=l-1}else throw new C({message:`Unexpected character ${p}`,characterIndex:r+1});break;case"(":t.push({type:"(",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case")":t.push({type:")",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case"[":t.push({type:"[",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case"]":t.push({type:"]",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case"{":t.push({type:"{",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case"}":t.push({type:"}",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case"'":{let l="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){l+=e[a],a=a+1,l+=e[a];continue}if(e[a]==="'"){r=a;break}l+=e[a]}if(l.length===1||l.length===2&&l[0]==="\\")t.push({type:"char",value:`'${l}'`,position:{row:o,column:s,character:u},modulePath:n,inputString:e});else throw new C({message:`Invalid char '${l}', expected char to have length 1.`,characterIndex:r});break}case'"':{let l="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){l+=e[a],a=a+1,l+=e[a];continue}if(e[a]==='"'){r=a;break}l+=e[a]}t.push({type:"string",value:`"${l}"`,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break}case"`":{let l="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){l+=e[a],a=a+1,l+=e[a];continue}if(e[a]==="`"){r=a;break}l+=e[a]}if(!O.test(l))throw new C({message:`Invalid backtick identifier \`${l}\``,characterIndex:r});t.push({type:"backtick_identifier",value:`\`${l}\``,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break}case",":t.push({type:",",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;case";":t.push({type:";",value:p,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;default:if(/[0-9]/.test(p)){let l=r,a=p;r=r+1;let g=/[0-9_]/;for(e[r-1]==="0"&&typeof e[r]=="string"&&(e[r]==="x"||e[r]==="X"?(a+=e[r],r=r+1,g=/[0-9A-Fa-f]/):e[r]==="b"||e[r]==="B"?(a+=e[r],r=r+1,g=/[01]/):(e[r]==="o"||e[r]==="O")&&(a+=e[r],r=r+1,g=/[0-7]/));typeof e[r]=="string"&&g.test(e[r]);)a+=e[r],r=r+1;if(e[r]==="."&&e[l-1]!=="."&&(e[r+1]??"").match(/[0-9]/)){for(a+=e[r],r=r+1;typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"float",value:a,position:{row:o,column:s,character:u},modulePath:n,inputString:e}),r=r-1}else{if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"integer",value:a,position:{row:o,column:s,character:u},modulePath:n,inputString:e}),r=r-1}}else if(/[_a-zA-Z\xA0-\uFFFF]/.test(p)){let l=p,a=r;for(r=r+1;typeof e[r]=="string"&&/[_a-zA-Z0-9\xA0-\uFFFF]/.test(e[r]);)l+=e[r],r=r+1;if(r=r-1,(e[r+1]==="!"||e[r+1]==="?")&&O.test(l+e[r+1])&&(r=r+1,l+=e[r]),O.test(l))switch(l){case"true":case"false":t.push({type:"bool",value:l,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break;default:t.push({type:"identifier",value:l,position:{row:o,column:s,character:u},modulePath:n,inputString:e});break}else throw new C({message:`Invalid identifier ${l}`,characterIndex:a})}else throw new C({message:`Unexpected character ${p}`,characterIndex:r});break}}return t}var N=class{constructor({modulePath:n,inputString:t}){this.modulePath=n,this.inputString=t,this.tokens=fe(t,n),this.program=[],this.parse(this.tokens)}skipWhitespace(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t+1;return t}skipWhitespaceBackward(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t-1;return t}isParenthesizedExpression(n,t,o){return t=this.skipWhitespace(n,t),o=this.skipWhitespaceBackward(n,o),!!n[t]&&n[t].type==="("&&!!n[o]&&n[o].type===")"&&ce(n,t)===o}parseParenExpr({tokens:n,index:t}){var p;let o=t;if(n[t].type!=="(")throw y({token:n[t],errorMessage:"Expected left paren"});if(((p=n[t+1])==null?void 0:p.type)===")")return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.tuple,position:n[t].position,modulePath:this.modulePath,inputString:this.inputString}},args:[],token:n[t]},index:t+2};let i=this.parseExpression({tokens:n,index:t+1}),r=i.expr;if(t=i.index,n[t].type===")")return{expr:r,index:t+1};{let s,u=[r];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ) or , for tuple"});if(n[t].type===","){if(!s||s===",")s=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in (...)'});t=t+1}else if(n[t].type===";"){if(!s||s===";")s=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in (...)'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type===")")break;let{expr:c,index:l}=this.parseExpression({tokens:n,index:t});u.push(c),t=l}let f=s===";"||!s;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:f?_.Tuple[0]:_.tuple,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:u,token:n[o]},index:t+1}}}parseArrayExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="[")throw y({token:n[t],errorMessage:"Expected left bracket"});t=t+1;let i,r=[];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ] or , for array"});if(n[t].type===","){if(!i||i===",")i=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in [...]'});t=t+1}else if(n[t].type===";"){if(!i||i===";")i=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in [...]'});t=t+1}if(n[t].type==="]")break;let{expr:f,index:c}=this.parseExpression({tokens:n,index:t});r.push(f),t=c}let p=i===";"||!i;if(p&&r.length>2)throw y({token:n[o],errorMessage:`Expected at 2 arguments for Array type, or 1 argument for Slice type, got ${r.length}`});let s=p&&r.length===2,u=p&&r.length===1;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:s?_.Array[0]:u?_.Slice[0]:_.array,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:r,token:n[o]},index:t+1}}parseCurlyBracketExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="{")throw y({token:n[t],errorMessage:"Expected left curly bracket"});let i=[],r;for(t=t+1;;){if(t=this.skipWhitespace(n,t),!n[t])throw y({token:n[t-1],errorMessage:'Unexpected end of curly bracket. Expected "}" or "," or ";"'});if(n[t].type===","){if(!r||r===",")r=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in {...}'});t=t+1}else if(n[t].type===";"){if(!r||r===";")r=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in {...}'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type==="}"){let u=n[this.skipWhitespaceBackward(n,t-1)];if(r===";"&&u&&(u.type===";"||u.type==="{")){let f={type:"identifier",value:_.tuple,position:u.position,modulePath:this.modulePath,inputString:this.inputString};i.push({tag:"FuncCall",func:{tag:"Atom",token:f},args:[],token:f})}break}let{expr:p,index:s}=this.parseExpression({tokens:n,index:t});i.push(p),t=s}if(r===","||!r){for(let s=0;s<i.length;s++){let u=i[s];if(k(u)){let f={type:"operator",value:":",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString},c={tag:"FuncCall",func:{tag:"Atom",token:f},isInfix:!0,args:[u,u],token:f};i[s]=c}}return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:"_",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}else return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.begin[0],position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}parsePrimary({tokens:n,index:t}){t=this.skipWhitespace(n,t);let o=n[t];if(!o)throw y({token:B,errorMessage:"Unexpected end of input"});let i=null;switch(o.type){case"identifier":case"operator":case"bool":case"integer":case"float":case"string":case"char":{i={expr:{tag:"Atom",token:o},index:t+1};break}case"(":{i=this.parseParenExpr({tokens:n,index:t});break}case"[":{i=this.parseArrayExpr({tokens:n,index:t});break}case"{":{i=this.parseCurlyBracketExpr({tokens:n,index:t});break}case".":{i={expr:{tag:"Atom",token:o},index:t+1};break}default:throw y({token:o,errorMessage:`Unexpected token "${o.type}"`})}return i}isOperatorAtLineStart(n,t){for(let o=n.length-1;o>=0;o--){let i=n[o];if(i.type==="whitespace"&&i.value.includes(`
|
|
16
|
+
`))return n.slice(o+1).every(s=>s.type==="whitespace");if(i.type!=="whitespace")return!1}return n.every(o=>o.type==="whitespace")}parseLeftAssociativeOperator({primaryExpr:n,operatorToken:t,rhs:o,tokens:i,index:r}){if(o.tag==="FuncCall"&&o.isInfix&&o.func.tag==="Atom"&&o.func.token.type!=="."){let p=o.args[0],s=o.args[1],u=o.func,f={tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,p],isInfix:!0,token:t};return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:u,args:[f,s],isInfix:!0,token:u.token},tokens:i,index:r})}else return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,o],isInfix:!0,token:t},tokens:i,index:r})}getExprMinimumColumnNumber(n){return k(n)?n.token.position.column:Math.min(this.getExprMinimumColumnNumber(n.func),...n.args.map(t=>this.getExprMinimumColumnNumber(t)))}parsePrimaryEnd({primaryExpr:n,tokens:t,index:o}){var f,c,l,a,g;let i=this.skipWhitespace(t,o),r=i!==o,p=((f=t[o-1])==null?void 0:f.type)==="whitespace";o=i;let s=t[i];if(!s||s.type===";"||s.type===","||s.type===")"||s.type==="]"||s.type==="}")return{expr:n,index:o};let u=n.tag==="Atom"&&n.token.type===".";if(u||s.type==="."&&!r&&!p&&((c=t[i+1])==null?void 0:c.type)!=="whitespace"){let{expr:d,index:v}=this.parsePrimary({tokens:t,index:u?o:o+1});o=v;let E={expr:{tag:"FuncCall",func:{tag:"Atom",token:u?n.token:s},args:u?[d]:[n,d],isInfix:!u,token:u?n.token:s},index:o};for(;t[o]&&t[o].type===".";){let{expr:L,index:se}=this.parsePrimary({tokens:t,index:o+1});E={expr:{tag:"FuncCall",func:{tag:"Atom",token:s},args:[E.expr,L],isInfix:!0,token:s},index:se},o=se}return this.parsePrimaryEnd({primaryExpr:E.expr,tokens:t,index:E.index})}else if((s.type==="operator"||s.type==="."&&!r||s.type==="backtick_identifier")&&((l=t[o+1])==null?void 0:l.type)!=="("){let d=this.skipWhitespace(t,o+1),{expr:v,index:E}=this.parseExpression({tokens:t,index:d});if(v.tag==="FuncCall"&&v.isInfix&&v.func.tag==="Atom"&&v.func.token.type!=="."&&!this.isParenthesizedExpression(t,d,E-1)){let L=`Ambiguous operator precedence.
|
|
17
|
+
Please use parentheses to clarify:
|
|
18
|
+
|
|
19
|
+
${T(n)} ${s.value} (${T(v)})
|
|
20
|
+
// or
|
|
21
|
+
(${T(n)} ${s.value} ${T(v.args[0])}) ${T(v.func)} ${T(v.args[1])}
|
|
22
|
+
|
|
23
|
+
Or use newline after "${s.value}" to confirm the right-associativity.
|
|
24
|
+
`,Ye=t.slice(o+1,d).some(xe=>xe.type==="whitespace"&&xe.value.includes(`
|
|
25
|
+
`)),m=t.slice(0,o),le=this.isOperatorAtLineStart(m,o),ue=t.slice(o+1,d),Qe=le&&ue.length>0&&((a=ue[0])==null?void 0:a.type)==="whitespace"&&((g=ue[0])==null?void 0:g.value.includes(`
|
|
26
|
+
`));if(!(Ye&&!le)){if(!Qe){if(le)return this.parseLeftAssociativeOperator({primaryExpr:n,operatorToken:s,rhs:v,tokens:t,index:E});throw y({token:s,errorMessage:L})}}}return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:s},args:[n,v],isInfix:!0,token:s},tokens:t,index:E})}else if(!r&&s.type==="("){let d=this.parseFunctionCall({func:n,tokens:t,index:o+1,hasWhitespace:!1});return this.parsePrimaryEnd({primaryExpr:d.expr,tokens:t,index:d.index})}else{let d=this.parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:!0});return this.parsePrimaryEnd({primaryExpr:d.expr,tokens:t,index:d.index})}}parseFunctionArguments({tokens:n,index:t,hasWhitespace:o}){var r;let i=[];if(t=this.skipWhitespace(n,t),!o&&((r=n[t])==null?void 0:r.type)===")")return{args:i,index:t+1};for(;;){let{expr:p,index:s}=this.parseExpression({tokens:n,index:t});i.push(p),t=s;let u=n[t];if((u==null?void 0:u.type)===",")t=t+1;else{if(!u||u.type===";"||u.type==="]"||u.type==="}")return{args:i,index:t};if(u.type===")")return{args:i,index:o?t:t+1};throw y({token:u,errorMessage:o?"Expected ; to end the function call":`Expected , to separate arguments
|
|
27
|
+
or ) to end the function call`})}}}parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:i}){let{args:r,index:p}=this.parseFunctionArguments({tokens:t,index:o,hasWhitespace:i});return o=p,{expr:{tag:"FuncCall",func:n,args:r,token:n.token},index:o}}parseExpression({tokens:n,index:t}){t=this.skipWhitespace(n,t);let{expr:o,index:i}=this.parsePrimary({tokens:n,index:t});return this.parsePrimaryEnd({primaryExpr:o,tokens:n,index:i})}programToString(){return this.program.map(t=>T(t)).join(`;
|
|
28
|
+
`)}parse(n){let t=0,o=[];for(;t<n.length;){switch(n[t].type){case"whitespace":case";":case"single_line_comment":case"multi_line_comment":{t=t+1;continue}}if(t>=n.length)break;try{let{expr:p,index:s}=this.parseExpression({tokens:n,index:t});o.push(p),t=s}catch(p){this.parserError=p;break}}let i=n[this.skipWhitespaceBackward(n,n.length-1)];if(i&&i.type===";"){let r={type:"identifier",value:_.tuple,position:i.position,modulePath:this.modulePath,inputString:this.inputString};o.push({tag:"FuncCall",func:{tag:"Atom",token:r},args:[],token:r})}this.program=o}getProgram(){return this.program}getParserError(){return this.parserError}getTokens(){return this.tokens}};function Z(e){let n=new N({modulePath:`auto-generated://
|
|
29
|
+
// === START auto-generated code ===
|
|
30
|
+
${e}
|
|
31
|
+
// === END auto-generated code ===
|
|
32
|
+
`,inputString:e});if(n.getParserError())throw n.getParserError();let t=n.getProgram();if(t.length!==1)throw new Error(`Expected exactly one expression from parsed code, got ${t.length}: "${e}"
|
|
33
|
+
${t.map(o=>T(o)).join(`
|
|
34
|
+
`)}
|
|
35
|
+
`);return t[0]}var Be=require("crypto");var mt=0;function Oe(){return`id${mt++}`}function dt(e){return"yo"+(0,Be.createHash)("sha1").update(e).digest("hex").slice(0,8)}var Le=new Map;function Te(e,n){let t="";for(let r=0;r<n.length;r++)if(w(n[r])){let p=K.indexOf(n[r]);t+=`${p}`}else t+=n[r];let o=dt(e)+"_"+t,i=Le.get(o);return i===void 0?i=0:i++,Le.set(o,i),o+(i==0?"":`_${i}`)}var he=null;function Ne(){if(he)return he;let e=Re(),n=De(e),t={id:"unit",tag:"unit",module:n};return n.receiverType=t,he=t,t}function De(e){return{id:`module_${Oe()}`,tag:"Module",fields:[],env:e,module:void 0}}function S(e){return(e==null?void 0:e.tag)==="FuncCall"}function k(e){return(e==null?void 0:e.tag)==="Atom"}function U(e){return e.tag==="Atom"&&e.token.type==="operator"}function P(e,n,t){if(e.tag!=="FuncCall"||e.func.tag!=="Atom")return!1;let o=e.func.token.value;return e.func.token.type==="backtick_identifier"&&(o=o.slice(1,-1)),e.tag==="FuncCall"&&e.func.tag==="Atom"&&(typeof n=="string"?o===n:n.includes(o))&&(t===void 0||e.args.length===t)}var _={compt:["compt"],ref:["ref"],forall:["forall","\u2200"],where:["where"],quote:["quote",":"],unquote:["unquote","#"],unquote_splicing:["unquote_splicing","...#"],return:["return"],recur:["recur"],fn:["fn"],unsafe_fn:["unsafe_fn"],extern:["extern"],cond:["cond"],type:["type"],match:["match"],test:["test"],struct:["struct"],object:["object"],newtype:["newtype"],enum:["enum"],union:["union"],module:["module"],impl:["impl"],Impl:["Impl"],begin:["begin"],module_begin:["module_begin"],import:["import"],export:["export"],open:["open"],clone:["clone","%"],break:["break"],continue:["continue"],while:["while"],if:["if"],op_and:["&&"],op_or:["||"],not:["not"],gensym:["gensym"],dyn:["dyn"],Dyn:["Dyn"],Fn:["Fn"],c_include:["c_include"],undefined:["undefined"],null:["null"],true:["true"],false:["false"],unique:["unique","^"],Ptr:["*"],Iso:["Iso"],Tuple:["Tuple"],Array:["Array"],Slice:["Slice"],Future:["Future"],Concrete:["Concrete"],Type:["Type"],Module:["Module"],ComptList:["ComptList"],tuple:"tuple",array:"array",compt_list:"compt_list"};function z(e){return!!(e.tag==="FuncCall"&&e.isInfix&&e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="backtick_identifier")&&e.args.length===2)}function T(e,n){let o={...{prettyPrint:!1,indentSize:2,maxLineLength:80,indentLevel:0},...n};return o.prettyPrint?h(e,o):b(e)}function b(e){let n="";switch(e.tag){case"Atom":{n=e.token.value;break}case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){e.func.token.value==="."?n=`${e.func.token.value}${b(e.args[0])}`:n=`${e.func.token.value}(${b(e.args[0])})`;break}else if(e.args.length===2&&e.isInfix){let i=b(e.args[0]),r=b(e.args[1]);i=z(e.args[0])||U(e.args[0])?`(${i})`:i,r=z(e.args[1])||U(e.args[1])?`(${r})`:r,e.func.token.value==="."?n=`(${i}.${r})`:n=`${i} ${e.func.token.value} ${r}`;break}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){e.args.length===1?n=`(${b(e.args[0])},)`:n=`(${e.args.map(i=>b(i)).join(", ").trim()})`;break}let t=b(e.func);t=z(e.func)||U(e.func)?`(${t})`:t;let o=e.args.map(i=>b(i)).join(", ").trim();n=`${t}(${o})`;break}}return n}function h(e,n){let t=" ".repeat(n.indentLevel*n.indentSize),o={...n,indentLevel:n.indentLevel+1},i=" ".repeat(o.indentLevel*n.indentSize);switch(e.tag){case"Atom":return e.token.value;case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){if(e.func.token.value===".")return`${e.func.token.value}${h(e.args[0],n)}`;{let f=h(e.args[0],n);return`${e.func.token.value}(${f})`}}else if(e.args.length===2&&e.isInfix){let f=h(e.args[0],n),c=h(e.args[1],n);return f=z(e.args[0])||U(e.args[0])?`(${f})`:f,c=z(e.args[1])||U(e.args[1])?`(${c})`:c,e.func.token.value==="."?`(${f}.${c})`:`${f} ${e.func.token.value} ${c}`}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){if(e.args.length===0)return"()";if(e.args.length===1)return`(${h(e.args[0],n)},)`;{let f=e.args.map(l=>h(l,n)),c=`(${f.join(", ")})`;return c.length<=n.maxLineLength?c:`(
|
|
36
|
+
${i}${f.join(`,
|
|
37
|
+
${i}`)}
|
|
38
|
+
${t})`}}let r=e.func.tag==="Atom"?e.func.token.value:null,p=r&&[..._.begin,..._.cond,..._.match,..._.fn,..._.if,..._.while].includes(r),s=h(e.func,n);if(s=z(e.func)||U(e.func)?`(${s})`:s,e.args.length===0)return`${s}()`;if(!p){let f=e.args.map(l=>h(l,n)),c=`${s}(${f.join(", ")})`;if(c.length<=n.maxLineLength)return c}if(p){if(r===_.begin[0]){if(e.args.length===1){let c=h(e.args[0],n);if(c.length<=n.maxLineLength&&!c.includes(`
|
|
39
|
+
`))return`${s}(${c})`}let f=e.args.map(c=>h(c,o));return`${s}(
|
|
40
|
+
${i}${f.join(`,
|
|
41
|
+
${i}`)}
|
|
42
|
+
${t})`}else if(r===_.cond[0]){let f=e.args.map(c=>{if(S(c)&&c.isInfix&&P(c,"=>")){let l=c.args[0],a=h(c.args[1],o),g=h(l,n);if(S(l)&&l.isInfix&&!P(l,"=>")&&(g=`(${g})`),a.includes(`
|
|
43
|
+
`)){let v=a.split(`
|
|
44
|
+
`).map((E,L)=>L===0?E:`${i}${E}`).join(`
|
|
45
|
+
`);return`${g} => ${v}`}else return`${g} => ${a}`}return h(c,o)});return`${s}(
|
|
46
|
+
${i}${f.join(`,
|
|
47
|
+
${i}`)}
|
|
48
|
+
${t})`}}let u=e.args.map(f=>h(f,o));return`${s}(
|
|
49
|
+
${i}${u.join(`,
|
|
50
|
+
${i}`)}
|
|
51
|
+
${t})`}}return b(e)}var Ft={tag:"Unit",type:Ne()};var ke=new Map,ae=new Map,wt=new Map;function We(e){for(let[n,t]of ae.entries()){let o=t.filter(i=>i.sourceModulePath!==e);o.length===0?ae.delete(n):ae.set(n,o)}}function He(){ke.clear(),ae.clear(),wt.clear()}function Ke(e){let n=ke.get(e);if(n){for(let t of n)t.fields=t.fields.filter(o=>o.sourceModulePath!==e);ke.delete(e)}}function Ze({modulePath:e,inputString:n}){return{functionDeclarationFrameLevel:-1,frames:[],freeVariables:[],modulePath:e,inputString:n}}function Re(){let e=Ze({modulePath:"",inputString:""});return j(e)}function j(e,n={id:Te(e.modulePath,"frame"),variables:[],isBeginBlockFrame:!1},t){let o=t?{...n,isBeginBlockFrame:!0}:n;return{functionDeclarationFrameLevel:e.functionDeclarationFrameLevel,freeVariables:e.freeVariables,frames:[...e.frames,o],modulePath:e.modulePath,inputString:e.inputString}}var Ba=process.env.YO_SKIP_PRELUDE==="1"||process.env.YO_SKIP_PRELUDE==="true";0&&(module.exports={IdentifierRegex,Operators,PlaceholderToken,RAIIToken,TokenType,charIsOperator,clearAllGlobalImplState,clearGenericImplsFromModule,clearImplsFromModule,findMatchingBracketTokenIndex,generateExprFromCode,stringIsOperator,tokenize});
|