@fugood/llama.node 0.2.3 → 0.3.1
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/CMakeLists.txt +6 -3
- package/bin/darwin/arm64/llama-node.node +0 -0
- package/bin/darwin/x64/llama-node.node +0 -0
- package/bin/linux/arm64/llama-node.node +0 -0
- package/bin/linux/x64/llama-node.node +0 -0
- package/bin/linux-vulkan/arm64/llama-node.node +0 -0
- package/bin/linux-vulkan/x64/llama-node.node +0 -0
- package/bin/win32/arm64/llama-node.node +0 -0
- package/bin/win32/arm64/node.lib +0 -0
- package/bin/win32/x64/llama-node.node +0 -0
- package/bin/win32/x64/node.lib +0 -0
- package/bin/win32-vulkan/arm64/llama-node.node +0 -0
- package/bin/win32-vulkan/arm64/node.lib +0 -0
- package/bin/win32-vulkan/x64/llama-node.node +0 -0
- package/bin/win32-vulkan/x64/node.lib +0 -0
- package/lib/binding.ts +8 -1
- package/package.json +3 -3
- package/patches/llama.patch +12 -12
- package/src/DetokenizeWorker.cpp +1 -1
- package/src/LlamaContext.cpp +33 -1
- package/src/LlamaContext.h +1 -0
- package/src/llama.cpp/.github/workflows/bench.yml +310 -0
- package/src/llama.cpp/.github/workflows/build.yml +1315 -0
- package/src/llama.cpp/.github/workflows/close-issue.yml +23 -0
- package/src/llama.cpp/.github/workflows/docker.yml +116 -0
- package/src/llama.cpp/.github/workflows/editorconfig.yml +27 -0
- package/src/llama.cpp/.github/workflows/gguf-publish.yml +44 -0
- package/src/llama.cpp/.github/workflows/labeler.yml +17 -0
- package/src/llama.cpp/.github/workflows/nix-ci-aarch64.yml +65 -0
- package/src/llama.cpp/.github/workflows/nix-ci.yml +72 -0
- package/src/llama.cpp/.github/workflows/nix-flake-update.yml +22 -0
- package/src/llama.cpp/.github/workflows/nix-publish-flake.yml +36 -0
- package/src/llama.cpp/.github/workflows/python-check-requirements.yml +35 -0
- package/src/llama.cpp/.github/workflows/python-lint.yml +23 -0
- package/src/llama.cpp/.github/workflows/python-type-check.yml +38 -0
- package/src/llama.cpp/.github/workflows/server.yml +183 -0
- package/src/llama.cpp/CMakeLists.txt +91 -1245
- package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +1 -1
- package/src/llama.cpp/cmake/build-info.cmake +58 -0
- package/src/llama.cpp/cmake/git-vars.cmake +22 -0
- package/src/llama.cpp/common/CMakeLists.txt +4 -3
- package/src/llama.cpp/common/build-info.cpp.in +4 -0
- package/src/llama.cpp/common/common.cpp +1116 -877
- package/src/llama.cpp/common/common.h +191 -77
- package/src/llama.cpp/common/grammar-parser.cpp +118 -31
- package/src/llama.cpp/common/json-schema-to-grammar.cpp +346 -65
- package/src/llama.cpp/common/log.h +1 -1
- package/src/llama.cpp/common/ngram-cache.h +10 -3
- package/src/llama.cpp/common/sampling.cpp +19 -10
- package/src/llama.cpp/docs/build.md +353 -0
- package/src/llama.cpp/examples/CMakeLists.txt +22 -22
- package/src/llama.cpp/examples/baby-llama/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/baby-llama/baby-llama.cpp +6 -6
- package/src/llama.cpp/examples/batched/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched/batched.cpp +52 -55
- package/src/llama.cpp/examples/batched-bench/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched-bench/batched-bench.cpp +20 -72
- package/src/llama.cpp/examples/benchmark/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/chat-13B.bat +57 -0
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/{finetune → cvector-generator}/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/cvector-generator/completions.txt +582 -0
- package/src/llama.cpp/examples/cvector-generator/cvector-generator.cpp +503 -0
- package/src/llama.cpp/examples/cvector-generator/mean.hpp +48 -0
- package/src/llama.cpp/examples/cvector-generator/negative.txt +4 -0
- package/src/llama.cpp/examples/cvector-generator/pca.hpp +325 -0
- package/src/llama.cpp/examples/cvector-generator/positive.txt +4 -0
- package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +35 -0
- package/src/llama.cpp/examples/embedding/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/embedding/embedding.cpp +94 -46
- package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +4 -6
- package/src/llama.cpp/examples/export-lora/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/export-lora/export-lora.cpp +344 -386
- package/src/llama.cpp/examples/gbnf-validator/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/gbnf-validator/gbnf-validator.cpp +30 -25
- package/src/llama.cpp/examples/gguf/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf/gguf.cpp +5 -0
- package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +15 -0
- package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +46 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +295 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +52 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +221 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +24 -0
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +42 -0
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +7093 -0
- package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +693 -0
- package/src/llama.cpp/examples/gguf-split/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf-split/gguf-split.cpp +3 -3
- package/src/llama.cpp/examples/gritlm/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gritlm/gritlm.cpp +6 -2
- package/src/llama.cpp/examples/imatrix/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/imatrix/imatrix.cpp +137 -176
- package/src/llama.cpp/examples/infill/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/infill/infill.cpp +38 -153
- package/src/llama.cpp/examples/llama-bench/llama-bench.cpp +175 -94
- package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +65 -0
- package/src/llama.cpp/examples/llama.android/build.gradle.kts +6 -0
- package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +68 -0
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +11 -7
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +2 -2
- package/src/llama.cpp/examples/llama.android/settings.gradle.kts +18 -0
- package/src/llama.cpp/examples/llava/CMakeLists.txt +6 -5
- package/src/llama.cpp/examples/llava/android/build_64.sh +8 -0
- package/src/llama.cpp/examples/llava/clip.cpp +23 -14
- package/src/llama.cpp/examples/llava/llava-cli.cpp +8 -6
- package/src/llama.cpp/examples/llava/requirements.txt +3 -2
- package/src/llama.cpp/examples/lookahead/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/lookahead/lookahead.cpp +2 -1
- package/src/llama.cpp/examples/lookup/CMakeLists.txt +4 -4
- package/src/llama.cpp/examples/lookup/lookup-create.cpp +2 -0
- package/src/llama.cpp/examples/lookup/lookup-merge.cpp +4 -4
- package/src/llama.cpp/examples/lookup/lookup-stats.cpp +2 -2
- package/src/llama.cpp/examples/lookup/lookup.cpp +1 -1
- package/src/llama.cpp/examples/main/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/main/main.cpp +98 -75
- package/src/llama.cpp/examples/main-cmake-pkg/CMakeLists.txt +4 -5
- package/src/llama.cpp/examples/parallel/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/parallel/parallel.cpp +2 -1
- package/src/llama.cpp/examples/passkey/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/passkey/passkey.cpp +23 -43
- package/src/llama.cpp/examples/perplexity/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/perplexity/perplexity.cpp +13 -10
- package/src/llama.cpp/examples/quantize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize/quantize.cpp +37 -34
- package/src/llama.cpp/examples/quantize-stats/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize-stats/quantize-stats.cpp +1 -1
- package/src/llama.cpp/examples/retrieval/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/retrieval/retrieval.cpp +26 -77
- package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +14 -7
- package/src/llama.cpp/examples/server/CMakeLists.txt +26 -2
- package/src/llama.cpp/examples/server/server.cpp +274 -671
- package/src/llama.cpp/examples/server/tests/requirements.txt +2 -2
- package/src/llama.cpp/examples/server/utils.hpp +28 -29
- package/src/llama.cpp/examples/simple/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/simple/simple.cpp +21 -29
- package/src/llama.cpp/examples/speculative/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/speculative/speculative.cpp +2 -1
- package/src/llama.cpp/examples/sycl/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/sycl/build.sh +23 -0
- package/src/llama.cpp/examples/sycl/run-llama2.sh +36 -0
- package/src/llama.cpp/examples/sycl/win-build-sycl.bat +33 -0
- package/src/llama.cpp/examples/sycl/win-run-llama2.bat +9 -0
- package/src/llama.cpp/examples/tokenize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/tokenize/tokenize.cpp +16 -2
- package/src/llama.cpp/ggml/CMakeLists.txt +253 -0
- package/src/llama.cpp/{cmake → ggml/cmake}/FindSIMD.cmake +6 -6
- package/src/llama.cpp/{ggml-backend.h → ggml/include/ggml-backend.h} +22 -17
- package/src/llama.cpp/ggml/include/ggml-blas.h +23 -0
- package/src/llama.cpp/ggml/include/ggml-cann.h +125 -0
- package/src/llama.cpp/{ggml-cuda.h → ggml/include/ggml-cuda.h} +3 -0
- package/src/llama.cpp/{ggml-metal.h → ggml/include/ggml-metal.h} +1 -2
- package/src/llama.cpp/{ggml-sycl.h → ggml/include/ggml-sycl.h} +3 -10
- package/src/llama.cpp/{ggml.h → ggml/include/ggml.h} +80 -85
- package/src/llama.cpp/ggml/src/CMakeLists.txt +1329 -0
- package/src/llama.cpp/ggml/src/ggml-aarch64.c +2193 -0
- package/src/llama.cpp/ggml/src/ggml-aarch64.h +39 -0
- package/src/llama.cpp/{ggml-alloc.c → ggml/src/ggml-alloc.c} +100 -49
- package/src/llama.cpp/{ggml-backend-impl.h → ggml/src/ggml-backend-impl.h} +20 -8
- package/src/llama.cpp/{ggml-backend.c → ggml/src/ggml-backend.c} +307 -167
- package/src/llama.cpp/ggml/src/ggml-blas.cpp +367 -0
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +198 -0
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +230 -0
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +2944 -0
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +592 -0
- package/src/llama.cpp/ggml/src/ggml-cann/common.h +282 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/CMakeLists.txt +32 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/ascendc_kernels.h +17 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/dup.cpp +223 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f16.cpp +186 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f32.cpp +180 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +193 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q8_0.cpp +191 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +208 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +206 -0
- package/src/llama.cpp/ggml/src/ggml-cann.cpp +2023 -0
- package/src/llama.cpp/{ggml-common.h → ggml/src/ggml-common.h} +41 -7
- package/src/llama.cpp/{ggml-impl.h → ggml/src/ggml-impl.h} +113 -9
- package/src/llama.cpp/{ggml-kompute.cpp → ggml/src/ggml-kompute.cpp} +33 -18
- package/src/llama.cpp/{ggml-quants.c → ggml/src/ggml-quants.c} +1460 -940
- package/src/llama.cpp/{ggml-quants.h → ggml/src/ggml-quants.h} +19 -20
- package/src/llama.cpp/{ggml-rpc.cpp → ggml/src/ggml-rpc.cpp} +95 -72
- package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +53 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +355 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +195 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +21 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +547 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +698 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +1023 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +3011 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +3031 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +33 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +1027 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +374 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +35 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +66 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +275 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +22 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +251 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +24 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +1140 -0
- package/src/llama.cpp/ggml/src/ggml-sycl.cpp +5314 -0
- package/src/llama.cpp/{ggml-vulkan.cpp → ggml/src/ggml-vulkan.cpp} +1781 -1868
- package/src/llama.cpp/{ggml.c → ggml/src/ggml.c} +1245 -2087
- package/src/llama.cpp/{sgemm.cpp → ggml/src/llamafile/sgemm.cpp} +21 -24
- package/src/llama.cpp/{sgemm.h → ggml/src/llamafile/sgemm.h} +1 -1
- package/src/llama.cpp/ggml/src/vulkan-shaders/CMakeLists.txt +5 -0
- package/src/llama.cpp/ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp +552 -0
- package/src/llama.cpp/{llama.h → include/llama.h} +175 -100
- package/src/llama.cpp/models/.editorconfig +1 -0
- package/src/llama.cpp/models/ggml-vocab-aquila.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-baichuan.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-neox.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +46 -0
- package/src/llama.cpp/pocs/vdot/CMakeLists.txt +2 -2
- package/src/llama.cpp/requirements/requirements-all.txt +12 -0
- package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +2 -0
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +3 -0
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +3 -0
- package/src/llama.cpp/requirements/{requirements-convert.txt → requirements-convert_legacy_llama.txt} +1 -1
- package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +1 -0
- package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +2 -0
- package/src/llama.cpp/requirements/requirements-pydantic.txt +3 -0
- package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +1 -0
- package/src/llama.cpp/requirements.txt +5 -4
- package/src/llama.cpp/scripts/build-info.sh +30 -0
- package/src/llama.cpp/scripts/install-oneapi.bat +19 -0
- package/src/llama.cpp/src/CMakeLists.txt +33 -0
- package/src/llama.cpp/src/llama-grammar.cpp +539 -0
- package/src/llama.cpp/src/llama-grammar.h +39 -0
- package/src/llama.cpp/src/llama-impl.h +26 -0
- package/src/llama.cpp/src/llama-sampling.cpp +635 -0
- package/src/llama.cpp/src/llama-sampling.h +56 -0
- package/src/llama.cpp/src/llama-vocab.cpp +1721 -0
- package/src/llama.cpp/src/llama-vocab.h +130 -0
- package/src/llama.cpp/{llama.cpp → src/llama.cpp} +5979 -5260
- package/src/llama.cpp/{unicode-data.cpp → src/unicode-data.cpp} +851 -802
- package/src/llama.cpp/{unicode.cpp → src/unicode.cpp} +52 -30
- package/src/llama.cpp/{unicode.h → src/unicode.h} +5 -1
- package/src/llama.cpp/tests/CMakeLists.txt +19 -20
- package/src/llama.cpp/tests/test-backend-ops.cpp +245 -67
- package/src/llama.cpp/tests/test-chat-template.cpp +57 -3
- package/src/llama.cpp/tests/test-double-float.cpp +2 -2
- package/src/llama.cpp/tests/test-grad0.cpp +2 -2
- package/src/llama.cpp/tests/test-grammar-integration.cpp +978 -31
- package/src/llama.cpp/tests/test-grammar-parser.cpp +423 -158
- package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +508 -135
- package/src/llama.cpp/tests/test-llama-grammar.cpp +15 -9
- package/src/llama.cpp/tests/test-quantize-fns.cpp +1 -1
- package/src/llama.cpp/tests/test-quantize-perf.cpp +1 -1
- package/src/llama.cpp/tests/test-rope.cpp +3 -4
- package/src/llama.cpp/tests/test-sampling.cpp +5 -5
- package/src/llama.cpp/tests/test-tokenizer-0.cpp +6 -6
- package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +20 -15
- package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +22 -11
- package/bin/darwin/arm64/default.metallib +0 -0
- package/bin/darwin/x64/default.metallib +0 -0
- package/src/llama.cpp/examples/beam-search/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/beam-search/beam-search.cpp +0 -188
- package/src/llama.cpp/examples/finetune/finetune.cpp +0 -1862
- package/src/llama.cpp/examples/llama.android/llama/CMakeLists.txt +0 -55
- package/src/llama.cpp/examples/train-text-from-scratch/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/train-text-from-scratch/train-text-from-scratch.cpp +0 -1253
- package/src/llama.cpp/ggml-opencl.cpp +0 -2305
- package/src/llama.cpp/ggml-opencl.h +0 -36
- package/src/llama.cpp/ggml-sycl.cpp +0 -17340
- package/src/llama.cpp/ggml-vulkan-shaders.hpp +0 -81211
- package/src/llama.cpp/requirements/requirements-convert-hf-to-gguf-update.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert-hf-to-gguf.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert-llama-ggml-to-gguf.txt +0 -1
- package/src/llama.cpp/scripts/gen-build-info-cpp.cmake +0 -24
- /package/src/llama.cpp/{ggml-alloc.h → ggml/include/ggml-alloc.h} +0 -0
- /package/src/llama.cpp/{ggml-kompute.h → ggml/include/ggml-kompute.h} +0 -0
- /package/src/llama.cpp/{ggml-rpc.h → ggml/include/ggml-rpc.h} +0 -0
- /package/src/llama.cpp/{ggml-vulkan.h → ggml/include/ggml-vulkan.h} +0 -0
- /package/src/llama.cpp/{unicode-data.h → src/unicode-data.h} +0 -0
|
@@ -80,6 +80,232 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
80
80
|
runner(tc);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
test({
|
|
84
|
+
SUCCESS,
|
|
85
|
+
"min 0",
|
|
86
|
+
R"""({
|
|
87
|
+
"type": "integer",
|
|
88
|
+
"minimum": 0
|
|
89
|
+
})""",
|
|
90
|
+
R"""(
|
|
91
|
+
root ::= ([0] | [1-9] [0-9]{0,15}) space
|
|
92
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
93
|
+
)"""
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test({
|
|
97
|
+
SUCCESS,
|
|
98
|
+
"min 1",
|
|
99
|
+
R"""({
|
|
100
|
+
"type": "integer",
|
|
101
|
+
"minimum": 1
|
|
102
|
+
})""",
|
|
103
|
+
R"""(
|
|
104
|
+
root ::= ([1-9] [0-9]{0,15}) space
|
|
105
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
106
|
+
)"""
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test({
|
|
110
|
+
SUCCESS,
|
|
111
|
+
"min 3",
|
|
112
|
+
R"""({
|
|
113
|
+
"type": "integer",
|
|
114
|
+
"minimum": 3
|
|
115
|
+
})""",
|
|
116
|
+
R"""(
|
|
117
|
+
root ::= ([1-2] [0-9]{1,15} | [3-9] [0-9]{0,15}) space
|
|
118
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
119
|
+
)"""
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test({
|
|
123
|
+
SUCCESS,
|
|
124
|
+
"min 9",
|
|
125
|
+
R"""({
|
|
126
|
+
"type": "integer",
|
|
127
|
+
"minimum": 9
|
|
128
|
+
})""",
|
|
129
|
+
R"""(
|
|
130
|
+
root ::= ([1-8] [0-9]{1,15} | [9] [0-9]{0,15}) space
|
|
131
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
132
|
+
)"""
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test({
|
|
136
|
+
SUCCESS,
|
|
137
|
+
"min 10",
|
|
138
|
+
R"""({
|
|
139
|
+
"type": "integer",
|
|
140
|
+
"minimum": 10
|
|
141
|
+
})""",
|
|
142
|
+
R"""(
|
|
143
|
+
root ::= ([1] ([0-9]{1,15}) | [2-9] [0-9]{1,15}) space
|
|
144
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
145
|
+
)"""
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test({
|
|
149
|
+
SUCCESS,
|
|
150
|
+
"min 25",
|
|
151
|
+
R"""({
|
|
152
|
+
"type": "integer",
|
|
153
|
+
"minimum": 25
|
|
154
|
+
})""",
|
|
155
|
+
R"""(
|
|
156
|
+
root ::= ([1] [0-9]{2,15} | [2] ([0-4] [0-9]{1,14} | [5-9] [0-9]{0,14}) | [3-9] [0-9]{1,15}) space
|
|
157
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
158
|
+
)"""
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test({
|
|
162
|
+
SUCCESS,
|
|
163
|
+
"max 30",
|
|
164
|
+
R"""({
|
|
165
|
+
"type": "integer",
|
|
166
|
+
"maximum": 30
|
|
167
|
+
})""",
|
|
168
|
+
R"""(
|
|
169
|
+
root ::= ("-" [1-9] [0-9]{0,15} | [0-9] | ([1-2] [0-9] | [3] "0")) space
|
|
170
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
171
|
+
)"""
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test({
|
|
175
|
+
SUCCESS,
|
|
176
|
+
"min -5",
|
|
177
|
+
R"""({
|
|
178
|
+
"type": "integer",
|
|
179
|
+
"minimum": -5
|
|
180
|
+
})""",
|
|
181
|
+
R"""(
|
|
182
|
+
root ::= ("-" ([0-5]) | [0] | [1-9] [0-9]{0,15}) space
|
|
183
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
184
|
+
)"""
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test({
|
|
188
|
+
SUCCESS,
|
|
189
|
+
"min -123",
|
|
190
|
+
R"""({
|
|
191
|
+
"type": "integer",
|
|
192
|
+
"minimum": -123
|
|
193
|
+
})""",
|
|
194
|
+
R"""(
|
|
195
|
+
root ::= ("-" ([0-9] | ([1-8] [0-9] | [9] [0-9]) | "1" ([0-1] [0-9] | [2] [0-3])) | [0] | [1-9] [0-9]{0,15}) space
|
|
196
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
197
|
+
)"""
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test({
|
|
201
|
+
SUCCESS,
|
|
202
|
+
"max -5",
|
|
203
|
+
R"""({
|
|
204
|
+
"type": "integer",
|
|
205
|
+
"maximum": -5
|
|
206
|
+
})""",
|
|
207
|
+
R"""(
|
|
208
|
+
root ::= ("-" ([0-4] [0-9]{1,15} | [5-9] [0-9]{0,15})) space
|
|
209
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
210
|
+
)"""
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test({
|
|
214
|
+
SUCCESS,
|
|
215
|
+
"max 1",
|
|
216
|
+
R"""({
|
|
217
|
+
"type": "integer",
|
|
218
|
+
"maximum": 1
|
|
219
|
+
})""",
|
|
220
|
+
R"""(
|
|
221
|
+
root ::= ("-" [1-9] [0-9]{0,15} | [0-1]) space
|
|
222
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
223
|
+
)"""
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test({
|
|
227
|
+
SUCCESS,
|
|
228
|
+
"max 100",
|
|
229
|
+
R"""({
|
|
230
|
+
"type": "integer",
|
|
231
|
+
"maximum": 100
|
|
232
|
+
})""",
|
|
233
|
+
R"""(
|
|
234
|
+
root ::= ("-" [1-9] [0-9]{0,15} | [0-9] | ([1-8] [0-9] | [9] [0-9]) | "100") space
|
|
235
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
236
|
+
)"""
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test({
|
|
240
|
+
SUCCESS,
|
|
241
|
+
"min 0 max 23",
|
|
242
|
+
R"""({
|
|
243
|
+
"type": "integer",
|
|
244
|
+
"minimum": 0,
|
|
245
|
+
"maximum": 23
|
|
246
|
+
})""",
|
|
247
|
+
R"""(
|
|
248
|
+
root ::= ([0-9] | ([1] [0-9] | [2] [0-3])) space
|
|
249
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
250
|
+
)"""
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test({
|
|
254
|
+
SUCCESS,
|
|
255
|
+
"min 15 max 300",
|
|
256
|
+
R"""({
|
|
257
|
+
"type": "integer",
|
|
258
|
+
"minimum": 15,
|
|
259
|
+
"maximum": 300
|
|
260
|
+
})""",
|
|
261
|
+
R"""(
|
|
262
|
+
root ::= (([1] ([5-9]) | [2-9] [0-9]) | ([1-2] [0-9]{2} | [3] "00")) space
|
|
263
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
264
|
+
)"""
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test({
|
|
268
|
+
SUCCESS,
|
|
269
|
+
"min 5 max 30",
|
|
270
|
+
R"""({
|
|
271
|
+
"type": "integer",
|
|
272
|
+
"minimum": 5,
|
|
273
|
+
"maximum": 30
|
|
274
|
+
})""",
|
|
275
|
+
R"""(
|
|
276
|
+
root ::= ([5-9] | ([1-2] [0-9] | [3] "0")) space
|
|
277
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
278
|
+
)"""
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test({
|
|
282
|
+
SUCCESS,
|
|
283
|
+
"min -123 max 42",
|
|
284
|
+
R"""({
|
|
285
|
+
"type": "integer",
|
|
286
|
+
"minimum": -123,
|
|
287
|
+
"maximum": 42
|
|
288
|
+
})""",
|
|
289
|
+
R"""(
|
|
290
|
+
root ::= ("-" ([0-9] | ([1-8] [0-9] | [9] [0-9]) | "1" ([0-1] [0-9] | [2] [0-3])) | [0-9] | ([1-3] [0-9] | [4] [0-2])) space
|
|
291
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
292
|
+
)"""
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test({
|
|
296
|
+
SUCCESS,
|
|
297
|
+
"min -10 max 10",
|
|
298
|
+
R"""({
|
|
299
|
+
"type": "integer",
|
|
300
|
+
"minimum": -10,
|
|
301
|
+
"maximum": 10
|
|
302
|
+
})""",
|
|
303
|
+
R"""(
|
|
304
|
+
root ::= ("-" ([0-9] | "10") | [0-9] | "10") space
|
|
305
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
306
|
+
)"""
|
|
307
|
+
});
|
|
308
|
+
|
|
83
309
|
test({
|
|
84
310
|
FAILURE,
|
|
85
311
|
"unknown type",
|
|
@@ -105,14 +331,14 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
105
331
|
R"""(
|
|
106
332
|
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
107
333
|
boolean ::= ("true" | "false") space
|
|
108
|
-
char ::= [^"
|
|
109
|
-
decimal-part ::= [0-9]
|
|
110
|
-
integral-part ::= [0
|
|
334
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
335
|
+
decimal-part ::= [0-9]{1,16}
|
|
336
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
111
337
|
null ::= "null" space
|
|
112
338
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
113
339
|
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
114
340
|
root ::= object
|
|
115
|
-
space ::= " "
|
|
341
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
116
342
|
string ::= "\"" char* "\"" space
|
|
117
343
|
value ::= object | array | string | number | boolean | null
|
|
118
344
|
)"""
|
|
@@ -130,18 +356,18 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
130
356
|
]
|
|
131
357
|
})""",
|
|
132
358
|
R"""(
|
|
133
|
-
date ::= [0-9]
|
|
359
|
+
date ::= [0-9]{4} "-" ( "0" [1-9] | "1" [0-2] ) "-" ( "0" [1-9] | [1-2] [0-9] | "3" [0-1] )
|
|
134
360
|
date-string ::= "\"" date "\"" space
|
|
135
361
|
date-time ::= date "T" time
|
|
136
362
|
date-time-string ::= "\"" date-time "\"" space
|
|
137
363
|
root ::= "[" space tuple-0 "," space uuid "," space tuple-2 "," space tuple-3 "]" space
|
|
138
|
-
space ::= " "
|
|
139
|
-
time ::= ([01] [0-9] | "2" [0-3]) ":" [0-5] [0-9] ":" [0-5] [0-9] ( "." [0-9]
|
|
364
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
365
|
+
time ::= ([01] [0-9] | "2" [0-3]) ":" [0-5] [0-9] ":" [0-5] [0-9] ( "." [0-9]{3} )? ( "Z" | ( "+" | "-" ) ( [01] [0-9] | "2" [0-3] ) ":" [0-5] [0-9] )
|
|
140
366
|
time-string ::= "\"" time "\"" space
|
|
141
367
|
tuple-0 ::= date-string
|
|
142
368
|
tuple-2 ::= time-string
|
|
143
369
|
tuple-3 ::= date-time-string
|
|
144
|
-
uuid ::= "\"" [0-9a-fA-F]
|
|
370
|
+
uuid ::= "\"" [0-9a-fA-F]{8} "-" [0-9a-fA-F]{4} "-" [0-9a-fA-F]{4} "-" [0-9a-fA-F]{4} "-" [0-9a-fA-F]{12} "\"" space
|
|
145
371
|
)"""
|
|
146
372
|
});
|
|
147
373
|
|
|
@@ -152,9 +378,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
152
378
|
"type": "string"
|
|
153
379
|
})""",
|
|
154
380
|
R"""(
|
|
155
|
-
char ::= [^"
|
|
381
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
156
382
|
root ::= "\"" char* "\"" space
|
|
157
|
-
space ::= " "
|
|
383
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
158
384
|
)"""
|
|
159
385
|
});
|
|
160
386
|
|
|
@@ -166,9 +392,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
166
392
|
"minLength": 1
|
|
167
393
|
})""",
|
|
168
394
|
R"""(
|
|
169
|
-
char ::= [^"
|
|
395
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
170
396
|
root ::= "\"" char+ "\"" space
|
|
171
|
-
space ::= " "
|
|
397
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
172
398
|
)"""
|
|
173
399
|
});
|
|
174
400
|
|
|
@@ -180,9 +406,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
180
406
|
"minLength": 3
|
|
181
407
|
})""",
|
|
182
408
|
R"""(
|
|
183
|
-
char ::= [^"
|
|
184
|
-
root ::= "\"" char
|
|
185
|
-
space ::= " "
|
|
409
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
410
|
+
root ::= "\"" char{3,} "\"" space
|
|
411
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
186
412
|
)"""
|
|
187
413
|
});
|
|
188
414
|
|
|
@@ -194,9 +420,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
194
420
|
"maxLength": 3
|
|
195
421
|
})""",
|
|
196
422
|
R"""(
|
|
197
|
-
char ::= [^"
|
|
198
|
-
root ::= "\""
|
|
199
|
-
space ::= " "
|
|
423
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
424
|
+
root ::= "\"" char{0,3} "\"" space
|
|
425
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
200
426
|
)"""
|
|
201
427
|
});
|
|
202
428
|
|
|
@@ -209,9 +435,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
209
435
|
"maxLength": 4
|
|
210
436
|
})""",
|
|
211
437
|
R"""(
|
|
212
|
-
char ::= [^"
|
|
213
|
-
root ::= "\"" char
|
|
214
|
-
space ::= " "
|
|
438
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
439
|
+
root ::= "\"" char{1,4} "\"" space
|
|
440
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
215
441
|
)"""
|
|
216
442
|
});
|
|
217
443
|
|
|
@@ -223,7 +449,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
223
449
|
})""",
|
|
224
450
|
R"""(
|
|
225
451
|
root ::= ("true" | "false") space
|
|
226
|
-
space ::= " "
|
|
452
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
227
453
|
)"""
|
|
228
454
|
});
|
|
229
455
|
|
|
@@ -234,9 +460,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
234
460
|
"type": "integer"
|
|
235
461
|
})""",
|
|
236
462
|
R"""(
|
|
237
|
-
integral-part ::= [0
|
|
463
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
238
464
|
root ::= ("-"? integral-part) space
|
|
239
|
-
space ::= " "
|
|
465
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
240
466
|
)"""
|
|
241
467
|
});
|
|
242
468
|
|
|
@@ -247,8 +473,8 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
247
473
|
"const": "foo"
|
|
248
474
|
})""",
|
|
249
475
|
R"""(
|
|
250
|
-
root ::= "\"foo\""
|
|
251
|
-
space ::= " "
|
|
476
|
+
root ::= "\"foo\"" space
|
|
477
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
252
478
|
)"""
|
|
253
479
|
});
|
|
254
480
|
|
|
@@ -259,8 +485,8 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
259
485
|
"const": 123
|
|
260
486
|
})""",
|
|
261
487
|
R"""(
|
|
262
|
-
root ::= "123"
|
|
263
|
-
space ::= " "
|
|
488
|
+
root ::= "123" space
|
|
489
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
264
490
|
)"""
|
|
265
491
|
});
|
|
266
492
|
|
|
@@ -271,8 +497,40 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
271
497
|
"enum": ["red", "amber", "green", null, 42, ["foo"]]
|
|
272
498
|
})""",
|
|
273
499
|
R"""(
|
|
274
|
-
root ::= "\"red\"" | "\"amber\"" | "\"green\"" | "null" | "42" | "[\"foo\"]"
|
|
275
|
-
space ::= " "
|
|
500
|
+
root ::= ("\"red\"" | "\"amber\"" | "\"green\"" | "null" | "42" | "[\"foo\"]") space
|
|
501
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
502
|
+
)"""
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test({
|
|
506
|
+
SUCCESS,
|
|
507
|
+
"string array",
|
|
508
|
+
R"""({
|
|
509
|
+
"type": "array",
|
|
510
|
+
"prefixItems": { "type": "string" }
|
|
511
|
+
})""",
|
|
512
|
+
R"""(
|
|
513
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
514
|
+
root ::= "[" space (string ("," space string)*)? "]" space
|
|
515
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
516
|
+
string ::= "\"" char* "\"" space
|
|
517
|
+
)"""
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
test({
|
|
521
|
+
SUCCESS,
|
|
522
|
+
"nullable string array",
|
|
523
|
+
R"""({
|
|
524
|
+
"type": ["array", "null"],
|
|
525
|
+
"prefixItems": { "type": "string" }
|
|
526
|
+
})""",
|
|
527
|
+
R"""(
|
|
528
|
+
alternative-0 ::= "[" space (string ("," space string)*)? "]" space
|
|
529
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
530
|
+
null ::= "null" space
|
|
531
|
+
root ::= alternative-0 | null
|
|
532
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
533
|
+
string ::= "\"" char* "\"" space
|
|
276
534
|
)"""
|
|
277
535
|
});
|
|
278
536
|
|
|
@@ -283,9 +541,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
283
541
|
"prefixItems": [{ "type": "string" }]
|
|
284
542
|
})""",
|
|
285
543
|
R"""(
|
|
286
|
-
char ::= [^"
|
|
544
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
287
545
|
root ::= "[" space string "]" space
|
|
288
|
-
space ::= " "
|
|
546
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
289
547
|
string ::= "\"" char* "\"" space
|
|
290
548
|
)"""
|
|
291
549
|
});
|
|
@@ -297,12 +555,12 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
297
555
|
"prefixItems": [{ "type": "string" }, { "type": "number" }]
|
|
298
556
|
})""",
|
|
299
557
|
R"""(
|
|
300
|
-
char ::= [^"
|
|
301
|
-
decimal-part ::= [0-9]
|
|
302
|
-
integral-part ::= [0
|
|
558
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
559
|
+
decimal-part ::= [0-9]{1,16}
|
|
560
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
303
561
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
304
562
|
root ::= "[" space string "," space number "]" space
|
|
305
|
-
space ::= " "
|
|
563
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
306
564
|
string ::= "\"" char* "\"" space
|
|
307
565
|
)"""
|
|
308
566
|
});
|
|
@@ -314,10 +572,10 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
314
572
|
"type": "number"
|
|
315
573
|
})""",
|
|
316
574
|
R"""(
|
|
317
|
-
decimal-part ::= [0-9]
|
|
318
|
-
integral-part ::= [0
|
|
575
|
+
decimal-part ::= [0-9]{1,16}
|
|
576
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
319
577
|
root ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
320
|
-
space ::= " "
|
|
578
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
321
579
|
)"""
|
|
322
580
|
});
|
|
323
581
|
|
|
@@ -332,8 +590,8 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
332
590
|
})""",
|
|
333
591
|
R"""(
|
|
334
592
|
boolean ::= ("true" | "false") space
|
|
335
|
-
root ::= "[" space boolean
|
|
336
|
-
space ::= " "
|
|
593
|
+
root ::= "[" space boolean ("," space boolean)+ "]" space
|
|
594
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
337
595
|
)"""
|
|
338
596
|
});
|
|
339
597
|
|
|
@@ -348,8 +606,8 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
348
606
|
})""",
|
|
349
607
|
R"""(
|
|
350
608
|
boolean ::= ("true" | "false") space
|
|
351
|
-
root ::= "[" space
|
|
352
|
-
space ::= " "
|
|
609
|
+
root ::= "[" space boolean? "]" space
|
|
610
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
353
611
|
)"""
|
|
354
612
|
});
|
|
355
613
|
|
|
@@ -365,7 +623,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
365
623
|
R"""(
|
|
366
624
|
boolean ::= ("true" | "false") space
|
|
367
625
|
root ::= "[" space (boolean ("," space boolean)?)? "]" space
|
|
368
|
-
space ::= " "
|
|
626
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
369
627
|
)"""
|
|
370
628
|
});
|
|
371
629
|
|
|
@@ -380,13 +638,51 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
380
638
|
"maxItems": 5
|
|
381
639
|
})""",
|
|
382
640
|
R"""(
|
|
383
|
-
decimal-part ::= [0-9]
|
|
641
|
+
decimal-part ::= [0-9]{1,16}
|
|
384
642
|
integer ::= ("-"? integral-part) space
|
|
385
|
-
integral-part ::= [0
|
|
643
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
386
644
|
item ::= number | integer
|
|
387
645
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
388
|
-
root ::= "[" space item
|
|
389
|
-
space ::= " "
|
|
646
|
+
root ::= "[" space item ("," space item){2,4} "]" space
|
|
647
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
648
|
+
)"""
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test({
|
|
652
|
+
SUCCESS,
|
|
653
|
+
"min + max items with min + max values across zero",
|
|
654
|
+
R"""({
|
|
655
|
+
"items": {
|
|
656
|
+
"type": "integer",
|
|
657
|
+
"minimum": -12,
|
|
658
|
+
"maximum": 207
|
|
659
|
+
},
|
|
660
|
+
"minItems": 3,
|
|
661
|
+
"maxItems": 5
|
|
662
|
+
})""",
|
|
663
|
+
R"""(
|
|
664
|
+
item ::= ("-" ([0-9] | "1" [0-2]) | [0-9] | ([1-8] [0-9] | [9] [0-9]) | ([1] [0-9]{2} | [2] "0" [0-7])) space
|
|
665
|
+
root ::= "[" space item ("," space item){2,4} "]" space
|
|
666
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
667
|
+
)"""
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
test({
|
|
671
|
+
SUCCESS,
|
|
672
|
+
"min + max items with min + max values",
|
|
673
|
+
R"""({
|
|
674
|
+
"items": {
|
|
675
|
+
"type": "integer",
|
|
676
|
+
"minimum": 12,
|
|
677
|
+
"maximum": 207
|
|
678
|
+
},
|
|
679
|
+
"minItems": 3,
|
|
680
|
+
"maxItems": 5
|
|
681
|
+
})""",
|
|
682
|
+
R"""(
|
|
683
|
+
item ::= (([1] ([2-9]) | [2-9] [0-9]) | ([1] [0-9]{2} | [2] "0" [0-7])) space
|
|
684
|
+
root ::= "[" space item ("," space item){2,4} "]" space
|
|
685
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
390
686
|
)"""
|
|
391
687
|
});
|
|
392
688
|
|
|
@@ -399,7 +695,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
399
695
|
})""",
|
|
400
696
|
R"""(
|
|
401
697
|
root ::= "\"" "ab" "c"? "d"* "ef" "g"+ ("hij")? "kl" "\"" space
|
|
402
|
-
space ::= " "
|
|
698
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
403
699
|
)"""
|
|
404
700
|
});
|
|
405
701
|
|
|
@@ -412,7 +708,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
412
708
|
})""",
|
|
413
709
|
R"""(
|
|
414
710
|
root ::= "\"" "[]{}()|+*?" "\"" space
|
|
415
|
-
space ::= " "
|
|
711
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
416
712
|
)"""
|
|
417
713
|
});
|
|
418
714
|
|
|
@@ -425,7 +721,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
425
721
|
})""",
|
|
426
722
|
R"""(
|
|
427
723
|
root ::= "\"" "\"" "\"" space
|
|
428
|
-
space ::= " "
|
|
724
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
429
725
|
)"""
|
|
430
726
|
});
|
|
431
727
|
|
|
@@ -438,9 +734,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
438
734
|
})""",
|
|
439
735
|
R"""(
|
|
440
736
|
dot ::= [^\x0A\x0D]
|
|
441
|
-
root ::= "\"" ("(" root-1
|
|
737
|
+
root ::= "\"" ("(" root-1{1,3} ")")? root-1{3,3} "-" root-1{4,4} " " "a"{3,5} "nd" dot dot dot "\"" space
|
|
442
738
|
root-1 ::= [0-9]
|
|
443
|
-
space ::= " "
|
|
739
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
444
740
|
)"""
|
|
445
741
|
});
|
|
446
742
|
|
|
@@ -466,9 +762,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
466
762
|
a-kv ::= "\"a\"" space ":" space string
|
|
467
763
|
b-kv ::= "\"b\"" space ":" space string
|
|
468
764
|
c-kv ::= "\"c\"" space ":" space string
|
|
469
|
-
char ::= [^"
|
|
765
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
470
766
|
root ::= "{" space b-kv "," space c-kv "," space a-kv "}" space
|
|
471
|
-
space ::= " "
|
|
767
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
472
768
|
string ::= "\"" char* "\"" space
|
|
473
769
|
)"""
|
|
474
770
|
});
|
|
@@ -486,9 +782,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
486
782
|
})""",
|
|
487
783
|
R"""(
|
|
488
784
|
a-kv ::= "\"a\"" space ":" space string
|
|
489
|
-
char ::= [^"
|
|
785
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
490
786
|
root ::= "{" space (a-kv )? "}" space
|
|
491
|
-
space ::= " "
|
|
787
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
492
788
|
string ::= "\"" char* "\"" space
|
|
493
789
|
)"""
|
|
494
790
|
});
|
|
@@ -510,9 +806,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
510
806
|
b-kv ::= "\"b\"" space ":" space string
|
|
511
807
|
b-rest ::= ( "," space c-kv )?
|
|
512
808
|
c-kv ::= "\"c\"" space ":" space string
|
|
513
|
-
char ::= [^"
|
|
809
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
514
810
|
root ::= "{" space (a-kv a-rest | b-kv b-rest | c-kv )? "}" space
|
|
515
|
-
space ::= " "
|
|
811
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
516
812
|
string ::= "\"" char* "\"" space
|
|
517
813
|
)"""
|
|
518
814
|
});
|
|
@@ -534,11 +830,11 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
534
830
|
a-kv ::= "\"a\"" space ":" space string
|
|
535
831
|
b-kv ::= "\"b\"" space ":" space string
|
|
536
832
|
c-kv ::= "\"c\"" space ":" space string
|
|
537
|
-
char ::= [^"
|
|
833
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
538
834
|
d-kv ::= "\"d\"" space ":" space string
|
|
539
835
|
d-rest ::= ( "," space c-kv )?
|
|
540
836
|
root ::= "{" space b-kv "," space a-kv ( "," space ( d-kv d-rest | c-kv ) )? "}" space
|
|
541
|
-
space ::= " "
|
|
837
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
542
838
|
string ::= "\"" char* "\"" space
|
|
543
839
|
)"""
|
|
544
840
|
});
|
|
@@ -552,14 +848,13 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
552
848
|
})""",
|
|
553
849
|
R"""(
|
|
554
850
|
additional-kv ::= string ":" space additional-value
|
|
555
|
-
additional-kvs ::= additional-kv ( "," space additional-kv )*
|
|
556
851
|
additional-value ::= "[" space (number ("," space number)*)? "]" space
|
|
557
|
-
char ::= [^"
|
|
558
|
-
decimal-part ::= [0-9]
|
|
559
|
-
integral-part ::= [0
|
|
852
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
853
|
+
decimal-part ::= [0-9]{1,16}
|
|
854
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
560
855
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
561
|
-
root ::= "{" space (additional-
|
|
562
|
-
space ::= " "
|
|
856
|
+
root ::= "{" space (additional-kv ( "," space additional-kv )* )? "}" space
|
|
857
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
563
858
|
string ::= "\"" char* "\"" space
|
|
564
859
|
)"""
|
|
565
860
|
});
|
|
@@ -574,14 +869,14 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
574
869
|
R"""(
|
|
575
870
|
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
576
871
|
boolean ::= ("true" | "false") space
|
|
577
|
-
char ::= [^"
|
|
578
|
-
decimal-part ::= [0-9]
|
|
579
|
-
integral-part ::= [0
|
|
872
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
873
|
+
decimal-part ::= [0-9]{1,16}
|
|
874
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
580
875
|
null ::= "null" space
|
|
581
876
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
582
877
|
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
583
878
|
root ::= object
|
|
584
|
-
space ::= " "
|
|
879
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
585
880
|
string ::= "\"" char* "\"" space
|
|
586
881
|
value ::= object | array | string | number | boolean | null
|
|
587
882
|
)"""
|
|
@@ -596,14 +891,14 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
596
891
|
R"""(
|
|
597
892
|
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
598
893
|
boolean ::= ("true" | "false") space
|
|
599
|
-
char ::= [^"
|
|
600
|
-
decimal-part ::= [0-9]
|
|
601
|
-
integral-part ::= [0
|
|
894
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
895
|
+
decimal-part ::= [0-9]{1,16}
|
|
896
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
602
897
|
null ::= "null" space
|
|
603
898
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
604
899
|
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
605
900
|
root ::= object
|
|
606
|
-
space ::= " "
|
|
901
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
607
902
|
string ::= "\"" char* "\"" space
|
|
608
903
|
value ::= object | array | string | number | boolean | null
|
|
609
904
|
)"""
|
|
@@ -618,7 +913,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
618
913
|
})""",
|
|
619
914
|
R"""(
|
|
620
915
|
root ::= "{" space "}" space
|
|
621
|
-
space ::= " "
|
|
916
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
622
917
|
)"""
|
|
623
918
|
});
|
|
624
919
|
|
|
@@ -635,14 +930,14 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
635
930
|
})""",
|
|
636
931
|
R"""(
|
|
637
932
|
a-kv ::= "\"a\"" space ":" space number
|
|
638
|
-
additional-
|
|
639
|
-
additional-
|
|
640
|
-
char ::= [^"
|
|
641
|
-
decimal-part ::= [0-9]
|
|
642
|
-
integral-part ::= [0
|
|
933
|
+
additional-k ::= ["] ( [a] char+ | [^"a] char* )? ["] space
|
|
934
|
+
additional-kv ::= additional-k ":" space string
|
|
935
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
936
|
+
decimal-part ::= [0-9]{1,16}
|
|
937
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
643
938
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
644
|
-
root ::= "{" space a-kv ( "," space ( additional-
|
|
645
|
-
space ::= " "
|
|
939
|
+
root ::= "{" space a-kv ( "," space ( additional-kv ( "," space additional-kv )* ) )? "}" space
|
|
940
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
646
941
|
string ::= "\"" char* "\"" space
|
|
647
942
|
)"""
|
|
648
943
|
});
|
|
@@ -659,16 +954,15 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
659
954
|
})""",
|
|
660
955
|
R"""(
|
|
661
956
|
a-kv ::= "\"a\"" space ":" space number
|
|
662
|
-
a-rest ::= additional-
|
|
663
|
-
additional-
|
|
664
|
-
additional-
|
|
665
|
-
char ::= [^"
|
|
666
|
-
decimal-part ::= [0-9]
|
|
667
|
-
integral-part ::= [0
|
|
957
|
+
a-rest ::= ( "," space additional-kv )*
|
|
958
|
+
additional-k ::= ["] ( [a] char+ | [^"a] char* )? ["] space
|
|
959
|
+
additional-kv ::= additional-k ":" space number
|
|
960
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
961
|
+
decimal-part ::= [0-9]{1,16}
|
|
962
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
668
963
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
669
|
-
root ::= "{" space (a-kv a-rest | additional-
|
|
670
|
-
space ::= " "
|
|
671
|
-
string ::= "\"" char* "\"" space
|
|
964
|
+
root ::= "{" space (a-kv a-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
965
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
672
966
|
)"""
|
|
673
967
|
});
|
|
674
968
|
|
|
@@ -678,25 +972,100 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
678
972
|
R"""({
|
|
679
973
|
"type": "object",
|
|
680
974
|
"properties": {
|
|
681
|
-
"
|
|
682
|
-
"
|
|
975
|
+
"and": {"type": "number"},
|
|
976
|
+
"also": {"type": "number"}
|
|
683
977
|
},
|
|
684
|
-
"required": ["
|
|
978
|
+
"required": ["and"],
|
|
685
979
|
"additionalProperties": {"type": "number"}
|
|
686
980
|
})""",
|
|
687
981
|
R"""(
|
|
688
|
-
|
|
689
|
-
additional-kv ::=
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
char ::= [^"
|
|
694
|
-
decimal-part ::= [0-9]
|
|
695
|
-
integral-part ::= [0
|
|
982
|
+
additional-k ::= ["] ( [a] ([l] ([s] ([o] char+ | [^"o] char*) | [^"s] char*) | [n] ([d] char+ | [^"d] char*) | [^"ln] char*) | [^"a] char* )? ["] space
|
|
983
|
+
additional-kv ::= additional-k ":" space number
|
|
984
|
+
also-kv ::= "\"also\"" space ":" space number
|
|
985
|
+
also-rest ::= ( "," space additional-kv )*
|
|
986
|
+
and-kv ::= "\"and\"" space ":" space number
|
|
987
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
988
|
+
decimal-part ::= [0-9]{1,16}
|
|
989
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
696
990
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
697
|
-
root ::= "{" space
|
|
698
|
-
space ::= " "
|
|
699
|
-
|
|
991
|
+
root ::= "{" space and-kv ( "," space ( also-kv also-rest | additional-kv ( "," space additional-kv )* ) )? "}" space
|
|
992
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
993
|
+
)"""
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
test({
|
|
997
|
+
SUCCESS,
|
|
998
|
+
"optional props with empty name",
|
|
999
|
+
R"""({
|
|
1000
|
+
"properties": {
|
|
1001
|
+
"": {"type": "integer"},
|
|
1002
|
+
"a": {"type": "integer"}
|
|
1003
|
+
},
|
|
1004
|
+
"additionalProperties": {"type": "integer"}
|
|
1005
|
+
})""",
|
|
1006
|
+
R"""(
|
|
1007
|
+
-kv ::= "\"\"" space ":" space root
|
|
1008
|
+
-rest ::= ( "," space a-kv )? a-rest
|
|
1009
|
+
a-kv ::= "\"a\"" space ":" space integer
|
|
1010
|
+
a-rest ::= ( "," space additional-kv )*
|
|
1011
|
+
additional-k ::= ["] ( [a] char+ | [^"a] char* ) ["] space
|
|
1012
|
+
additional-kv ::= additional-k ":" space integer
|
|
1013
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1014
|
+
integer ::= ("-"? integral-part) space
|
|
1015
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1016
|
+
root ::= ("-"? integral-part) space
|
|
1017
|
+
root0 ::= "{" space (-kv -rest | a-kv a-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1018
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
1019
|
+
)"""
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
test({
|
|
1023
|
+
SUCCESS,
|
|
1024
|
+
"optional props with nested names",
|
|
1025
|
+
R"""({
|
|
1026
|
+
"properties": {
|
|
1027
|
+
"a": {"type": "integer"},
|
|
1028
|
+
"aa": {"type": "integer"}
|
|
1029
|
+
},
|
|
1030
|
+
"additionalProperties": {"type": "integer"}
|
|
1031
|
+
})""",
|
|
1032
|
+
R"""(
|
|
1033
|
+
a-kv ::= "\"a\"" space ":" space integer
|
|
1034
|
+
a-rest ::= ( "," space aa-kv )? aa-rest
|
|
1035
|
+
aa-kv ::= "\"aa\"" space ":" space integer
|
|
1036
|
+
aa-rest ::= ( "," space additional-kv )*
|
|
1037
|
+
additional-k ::= ["] ( [a] ([a] char+ | [^"a] char*) | [^"a] char* )? ["] space
|
|
1038
|
+
additional-kv ::= additional-k ":" space integer
|
|
1039
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1040
|
+
integer ::= ("-"? integral-part) space
|
|
1041
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1042
|
+
root ::= "{" space (a-kv a-rest | aa-kv aa-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1043
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
1044
|
+
)"""
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
test({
|
|
1048
|
+
SUCCESS,
|
|
1049
|
+
"optional props with common prefix",
|
|
1050
|
+
R"""({
|
|
1051
|
+
"properties": {
|
|
1052
|
+
"ab": {"type": "integer"},
|
|
1053
|
+
"ac": {"type": "integer"}
|
|
1054
|
+
},
|
|
1055
|
+
"additionalProperties": {"type": "integer"}
|
|
1056
|
+
})""",
|
|
1057
|
+
R"""(
|
|
1058
|
+
ab-kv ::= "\"ab\"" space ":" space integer
|
|
1059
|
+
ab-rest ::= ( "," space ac-kv )? ac-rest
|
|
1060
|
+
ac-kv ::= "\"ac\"" space ":" space integer
|
|
1061
|
+
ac-rest ::= ( "," space additional-kv )*
|
|
1062
|
+
additional-k ::= ["] ( [a] ([b] char+ | [c] char+ | [^"bc] char*) | [^"a] char* )? ["] space
|
|
1063
|
+
additional-kv ::= additional-k ":" space integer
|
|
1064
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1065
|
+
integer ::= ("-"? integral-part) space
|
|
1066
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1067
|
+
root ::= "{" space (ab-kv ab-rest | ac-kv ac-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1068
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
700
1069
|
)"""
|
|
701
1070
|
});
|
|
702
1071
|
|
|
@@ -721,11 +1090,11 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
721
1090
|
}
|
|
722
1091
|
})""",
|
|
723
1092
|
R"""(
|
|
724
|
-
char ::= [^"
|
|
1093
|
+
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
725
1094
|
foo ::= "{" space foo-a-kv "}" space
|
|
726
1095
|
foo-a-kv ::= "\"a\"" space ":" space string
|
|
727
1096
|
root ::= foo
|
|
728
|
-
space ::= " "
|
|
1097
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
729
1098
|
string ::= "\"" char* "\"" space
|
|
730
1099
|
)"""
|
|
731
1100
|
});
|
|
@@ -753,13 +1122,13 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
753
1122
|
alternative-1 ::= bar
|
|
754
1123
|
bar ::= "{" space (bar-b-kv )? "}" space
|
|
755
1124
|
bar-b-kv ::= "\"b\"" space ":" space number
|
|
756
|
-
decimal-part ::= [0-9]
|
|
1125
|
+
decimal-part ::= [0-9]{1,16}
|
|
757
1126
|
foo ::= "{" space (foo-a-kv )? "}" space
|
|
758
1127
|
foo-a-kv ::= "\"a\"" space ":" space number
|
|
759
|
-
integral-part ::= [0
|
|
1128
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
760
1129
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
761
1130
|
root ::= alternative-0 | alternative-1
|
|
762
|
-
space ::= " "
|
|
1131
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
763
1132
|
)"""
|
|
764
1133
|
});
|
|
765
1134
|
|
|
@@ -799,11 +1168,11 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
799
1168
|
c-kv ::= "\"c\"" space ":" space number
|
|
800
1169
|
d-kv ::= "\"d\"" space ":" space number
|
|
801
1170
|
d-rest ::= ( "," space c-kv )?
|
|
802
|
-
decimal-part ::= [0-9]
|
|
803
|
-
integral-part ::= [0
|
|
1171
|
+
decimal-part ::= [0-9]{1,16}
|
|
1172
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
804
1173
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
805
1174
|
root ::= "{" space a-kv "," space b-kv ( "," space ( d-kv d-rest | c-kv ) )? "}" space
|
|
806
|
-
space ::= " "
|
|
1175
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
807
1176
|
)"""
|
|
808
1177
|
});
|
|
809
1178
|
|
|
@@ -842,8 +1211,8 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
842
1211
|
"definitions": {}
|
|
843
1212
|
})""",
|
|
844
1213
|
R"""(
|
|
845
|
-
decimal-part ::= [0-9]
|
|
846
|
-
integral-part ::= [0
|
|
1214
|
+
decimal-part ::= [0-9]{1,16}
|
|
1215
|
+
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
847
1216
|
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
848
1217
|
number- ::= "{" space number-number-kv "}" space
|
|
849
1218
|
number-kv ::= "\"number\"" space ":" space number-
|
|
@@ -851,7 +1220,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|
|
851
1220
|
number-number-kv ::= "\"number\"" space ":" space number-number
|
|
852
1221
|
number-number-root-kv ::= "\"root\"" space ":" space number
|
|
853
1222
|
root ::= "{" space number-kv "}" space
|
|
854
|
-
space ::= " "
|
|
1223
|
+
space ::= | " " | "\n" [ \t]{0,20}
|
|
855
1224
|
)"""
|
|
856
1225
|
});
|
|
857
1226
|
}
|
|
@@ -870,26 +1239,30 @@ int main() {
|
|
|
870
1239
|
}
|
|
871
1240
|
});
|
|
872
1241
|
|
|
873
|
-
if (getenv("
|
|
874
|
-
|
|
875
|
-
write("test-json-schema-input.tmp", tc.schema);
|
|
876
|
-
tc.verify_status(std::system(
|
|
877
|
-
"python ./examples/json_schema_to_grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
|
878
|
-
tc.verify(read("test-grammar-output.tmp"));
|
|
879
|
-
});
|
|
1242
|
+
if (getenv("LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR")) {
|
|
1243
|
+
fprintf(stderr, "\033[33mWARNING: Skipping slow tests on emulator.\n\033[0m");
|
|
880
1244
|
} else {
|
|
881
|
-
|
|
882
|
-
|
|
1245
|
+
if (getenv("LLAMA_PYTHON_AVAILABLE") || (std::system("python -c \"import sys; exit(1) if sys.version_info < (3, 8) else print('Python version is sufficient')\"") == 0)) {
|
|
1246
|
+
test_all("Python", [](const TestCase & tc) {
|
|
1247
|
+
write("test-json-schema-input.tmp", tc.schema);
|
|
1248
|
+
tc.verify_status(std::system(
|
|
1249
|
+
"python ./examples/json_schema_to_grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
|
1250
|
+
tc.verify(read("test-grammar-output.tmp"));
|
|
1251
|
+
});
|
|
1252
|
+
} else {
|
|
1253
|
+
fprintf(stderr, "\033[33mWARNING: Python not found (min version required is 3.8), skipping Python JSON schema -> grammar tests.\n\033[0m");
|
|
1254
|
+
}
|
|
883
1255
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1256
|
+
if (getenv("LLAMA_NODE_AVAILABLE") || (std::system("node --version") == 0)) {
|
|
1257
|
+
test_all("JavaScript", [](const TestCase & tc) {
|
|
1258
|
+
write("test-json-schema-input.tmp", tc.schema);
|
|
1259
|
+
tc.verify_status(std::system(
|
|
1260
|
+
"node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
|
1261
|
+
tc.verify(read("test-grammar-output.tmp"));
|
|
1262
|
+
});
|
|
1263
|
+
} else {
|
|
1264
|
+
fprintf(stderr, "\033[33mWARNING: Node not found, skipping JavaScript JSON schema -> grammar tests.\n\033[0m");
|
|
1265
|
+
}
|
|
893
1266
|
}
|
|
894
1267
|
|
|
895
1268
|
test_all("Check Expectations Validity", [](const TestCase & tc) {
|