@fugood/llama.node 0.6.3 → 1.0.0-beta.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/CMakeLists.txt +40 -30
- package/README.md +4 -1
- package/lib/binding.js +41 -29
- package/lib/binding.ts +26 -25
- package/package.json +40 -7
- package/scripts/build.js +47 -0
- package/scripts/llama.cpp.patch +109 -0
- package/src/anyascii.c +22223 -0
- package/src/anyascii.h +42 -0
- package/src/tts_utils.cpp +20 -7
- package/src/tts_utils.h +2 -0
- 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-cuda/arm64/llama-node.node +0 -0
- package/bin/linux-cuda/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/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/src/llama.cpp/.github/workflows/build-linux-cross.yml +0 -233
- package/src/llama.cpp/.github/workflows/build.yml +0 -1078
- package/src/llama.cpp/.github/workflows/close-issue.yml +0 -28
- package/src/llama.cpp/.github/workflows/docker.yml +0 -178
- package/src/llama.cpp/.github/workflows/editorconfig.yml +0 -29
- package/src/llama.cpp/.github/workflows/gguf-publish.yml +0 -44
- package/src/llama.cpp/.github/workflows/labeler.yml +0 -17
- package/src/llama.cpp/.github/workflows/python-check-requirements.yml +0 -33
- package/src/llama.cpp/.github/workflows/python-lint.yml +0 -30
- package/src/llama.cpp/.github/workflows/python-type-check.yml +0 -40
- package/src/llama.cpp/.github/workflows/release.yml +0 -739
- package/src/llama.cpp/.github/workflows/server.yml +0 -237
- package/src/llama.cpp/.github/workflows/winget.yml +0 -42
- package/src/llama.cpp/cmake/arm64-apple-clang.cmake +0 -16
- package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +0 -16
- package/src/llama.cpp/cmake/build-info.cmake +0 -64
- package/src/llama.cpp/cmake/common.cmake +0 -35
- package/src/llama.cpp/cmake/git-vars.cmake +0 -22
- package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -5
- package/src/llama.cpp/common/build-info.cpp.in +0 -4
- package/src/llama.cpp/docs/build.md +0 -561
- package/src/llama.cpp/examples/CMakeLists.txt +0 -43
- package/src/llama.cpp/examples/batched/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/batched/batched.cpp +0 -246
- package/src/llama.cpp/examples/chat-13B.bat +0 -57
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +0 -941
- package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +0 -35
- package/src/llama.cpp/examples/embedding/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/embedding/embedding.cpp +0 -323
- package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +0 -10
- package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +0 -194
- package/src/llama.cpp/examples/gen-docs/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gen-docs/gen-docs.cpp +0 -83
- package/src/llama.cpp/examples/gguf/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gguf/gguf.cpp +0 -265
- package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +0 -22
- package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +0 -46
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +0 -295
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +0 -52
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +0 -221
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +0 -24
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +0 -42
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +0 -7093
- package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +0 -694
- package/src/llama.cpp/examples/gritlm/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gritlm/gritlm.cpp +0 -229
- package/src/llama.cpp/examples/jeopardy/questions.txt +0 -100
- package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +0 -65
- package/src/llama.cpp/examples/llama.android/build.gradle.kts +0 -6
- package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +0 -71
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +0 -53
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +0 -452
- package/src/llama.cpp/examples/llama.android/settings.gradle.kts +0 -18
- package/src/llama.cpp/examples/lookahead/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/lookahead/lookahead.cpp +0 -472
- package/src/llama.cpp/examples/lookup/CMakeLists.txt +0 -23
- package/src/llama.cpp/examples/lookup/lookup-create.cpp +0 -40
- package/src/llama.cpp/examples/lookup/lookup-merge.cpp +0 -47
- package/src/llama.cpp/examples/lookup/lookup-stats.cpp +0 -157
- package/src/llama.cpp/examples/lookup/lookup.cpp +0 -242
- package/src/llama.cpp/examples/parallel/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/parallel/parallel.cpp +0 -492
- package/src/llama.cpp/examples/passkey/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/passkey/passkey.cpp +0 -277
- package/src/llama.cpp/examples/retrieval/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/retrieval/retrieval.cpp +0 -304
- package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +0 -246
- package/src/llama.cpp/examples/simple/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/simple/simple.cpp +0 -206
- package/src/llama.cpp/examples/simple-chat/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/simple-chat/simple-chat.cpp +0 -206
- package/src/llama.cpp/examples/simple-cmake-pkg/CMakeLists.txt +0 -11
- package/src/llama.cpp/examples/speculative/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/speculative/speculative.cpp +0 -644
- package/src/llama.cpp/examples/speculative-simple/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +0 -261
- package/src/llama.cpp/examples/sycl/CMakeLists.txt +0 -9
- package/src/llama.cpp/examples/sycl/build.sh +0 -23
- package/src/llama.cpp/examples/sycl/ls-sycl-device.cpp +0 -13
- package/src/llama.cpp/examples/sycl/run-llama2.sh +0 -27
- package/src/llama.cpp/examples/sycl/run-llama3.sh +0 -28
- package/src/llama.cpp/examples/sycl/win-build-sycl.bat +0 -33
- package/src/llama.cpp/examples/sycl/win-run-llama2.bat +0 -9
- package/src/llama.cpp/examples/sycl/win-run-llama3.bat +0 -9
- package/src/llama.cpp/examples/training/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/training/finetune.cpp +0 -96
- package/src/llama.cpp/ggml/cmake/GitVars.cmake +0 -22
- package/src/llama.cpp/ggml/cmake/common.cmake +0 -26
- package/src/llama.cpp/ggml/src/ggml-alloc.c +0 -1042
- package/src/llama.cpp/ggml/src/ggml-backend-impl.h +0 -255
- package/src/llama.cpp/ggml/src/ggml-backend-reg.cpp +0 -586
- package/src/llama.cpp/ggml/src/ggml-backend.cpp +0 -2008
- package/src/llama.cpp/ggml/src/ggml-blas/CMakeLists.txt +0 -87
- package/src/llama.cpp/ggml/src/ggml-blas/ggml-blas.cpp +0 -517
- package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +0 -74
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +0 -179
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +0 -258
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +0 -2863
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +0 -1110
- package/src/llama.cpp/ggml/src/ggml-cann/common.h +0 -420
- package/src/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +0 -2570
- package/src/llama.cpp/ggml/src/ggml-common.h +0 -1857
- package/src/llama.cpp/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +0 -100
- package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +0 -184
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/cuda.h +0 -15
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +0 -243
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +0 -140
- package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +0 -131
- package/src/llama.cpp/ggml/src/ggml-impl.h +0 -601
- package/src/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +0 -166
- package/src/llama.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +0 -2251
- package/src/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +0 -120
- package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +0 -622
- package/src/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +0 -113
- package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +0 -96
- package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -5124
- package/src/llama.cpp/ggml/src/ggml-opt.cpp +0 -1037
- package/src/llama.cpp/ggml/src/ggml-quants.c +0 -5232
- package/src/llama.cpp/ggml/src/ggml-quants.h +0 -100
- package/src/llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +0 -9
- package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +0 -1813
- package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +0 -189
- package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +0 -37
- package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +0 -239
- package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.hpp +0 -39
- package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +0 -83
- package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +0 -493
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +0 -197
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/conv.cpp +0 -100
- package/src/llama.cpp/ggml/src/ggml-sycl/conv.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +0 -623
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +0 -34
- package/src/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +0 -701
- package/src/llama.cpp/ggml/src/ggml-sycl/cpy.hpp +0 -11
- package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +0 -791
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +0 -1160
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +0 -27
- package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +0 -2957
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -1536
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +0 -75
- package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +0 -99
- package/src/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +0 -311
- package/src/llama.cpp/ggml/src/ggml-sycl/getrows.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +0 -4443
- package/src/llama.cpp/ggml/src/ggml-sycl/gla.cpp +0 -105
- package/src/llama.cpp/ggml/src/ggml-sycl/gla.hpp +0 -8
- package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +0 -136
- package/src/llama.cpp/ggml/src/ggml-sycl/im2col.hpp +0 -21
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +0 -3030
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +0 -33
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +0 -1108
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +0 -27
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +0 -474
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +0 -26
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +0 -46
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.hpp +0 -10
- package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +0 -74
- package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +0 -83
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +0 -362
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +0 -264
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +0 -13
- package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +0 -23
- package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +0 -73
- package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +0 -1215
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv.cpp +0 -305
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv.hpp +0 -10
- package/src/llama.cpp/ggml/src/ggml-threading.cpp +0 -12
- package/src/llama.cpp/ggml/src/ggml-threading.h +0 -14
- package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +0 -196
- package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +0 -10699
- package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +0 -39
- package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +0 -751
- package/src/llama.cpp/ggml/src/ggml.c +0 -6550
- package/src/llama.cpp/ggml/src/gguf.cpp +0 -1330
- package/src/llama.cpp/models/.editorconfig +0 -1
- 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 +0 -112
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.out +0 -46
- 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 +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-llama4.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama4.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +0 -46
- package/src/llama.cpp/pocs/CMakeLists.txt +0 -14
- package/src/llama.cpp/pocs/vdot/CMakeLists.txt +0 -9
- package/src/llama.cpp/pocs/vdot/q8dot.cpp +0 -173
- package/src/llama.cpp/pocs/vdot/vdot.cpp +0 -311
- package/src/llama.cpp/prompts/LLM-questions.txt +0 -49
- package/src/llama.cpp/prompts/alpaca.txt +0 -1
- package/src/llama.cpp/prompts/assistant.txt +0 -31
- package/src/llama.cpp/prompts/chat-with-baichuan.txt +0 -4
- package/src/llama.cpp/prompts/chat-with-bob.txt +0 -7
- package/src/llama.cpp/prompts/chat-with-qwen.txt +0 -1
- package/src/llama.cpp/prompts/chat-with-vicuna-v0.txt +0 -7
- package/src/llama.cpp/prompts/chat-with-vicuna-v1.txt +0 -7
- package/src/llama.cpp/prompts/chat.txt +0 -28
- package/src/llama.cpp/prompts/dan-modified.txt +0 -1
- package/src/llama.cpp/prompts/dan.txt +0 -1
- package/src/llama.cpp/prompts/mnemonics.txt +0 -93
- package/src/llama.cpp/prompts/parallel-questions.txt +0 -43
- package/src/llama.cpp/prompts/reason-act.txt +0 -18
- package/src/llama.cpp/requirements/requirements-all.txt +0 -15
- package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +0 -7
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +0 -7
- package/src/llama.cpp/requirements/requirements-convert_legacy_llama.txt +0 -5
- package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +0 -1
- package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +0 -4
- package/src/llama.cpp/requirements/requirements-gguf_editor_gui.txt +0 -3
- package/src/llama.cpp/requirements/requirements-pydantic.txt +0 -3
- package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +0 -1
- package/src/llama.cpp/requirements/requirements-tool_bench.txt +0 -12
- package/src/llama.cpp/requirements.txt +0 -13
- package/src/llama.cpp/scripts/build-info.sh +0 -30
- package/src/llama.cpp/scripts/install-oneapi.bat +0 -19
- package/src/llama.cpp/scripts/xxd.cmake +0 -16
- package/src/llama.cpp/tests/CMakeLists.txt +0 -177
- package/src/llama.cpp/tests/get-model.cpp +0 -21
- package/src/llama.cpp/tests/get-model.h +0 -2
- package/src/llama.cpp/tests/test-arg-parser.cpp +0 -178
- package/src/llama.cpp/tests/test-autorelease.cpp +0 -24
- package/src/llama.cpp/tests/test-backend-ops.cpp +0 -4793
- package/src/llama.cpp/tests/test-barrier.cpp +0 -94
- package/src/llama.cpp/tests/test-c.c +0 -7
- package/src/llama.cpp/tests/test-chat-template.cpp +0 -417
- package/src/llama.cpp/tests/test-chat.cpp +0 -985
- package/src/llama.cpp/tests/test-double-float.cpp +0 -57
- package/src/llama.cpp/tests/test-gbnf-validator.cpp +0 -109
- package/src/llama.cpp/tests/test-gguf.cpp +0 -1338
- package/src/llama.cpp/tests/test-grammar-integration.cpp +0 -1308
- package/src/llama.cpp/tests/test-grammar-llguidance.cpp +0 -1201
- package/src/llama.cpp/tests/test-grammar-parser.cpp +0 -519
- package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +0 -1304
- package/src/llama.cpp/tests/test-llama-grammar.cpp +0 -408
- package/src/llama.cpp/tests/test-log.cpp +0 -39
- package/src/llama.cpp/tests/test-model-load-cancel.cpp +0 -27
- package/src/llama.cpp/tests/test-mtmd-c-api.c +0 -63
- package/src/llama.cpp/tests/test-opt.cpp +0 -904
- package/src/llama.cpp/tests/test-quantize-fns.cpp +0 -186
- package/src/llama.cpp/tests/test-quantize-perf.cpp +0 -365
- package/src/llama.cpp/tests/test-quantize-stats.cpp +0 -424
- package/src/llama.cpp/tests/test-regex-partial.cpp +0 -288
- package/src/llama.cpp/tests/test-rope.cpp +0 -262
- package/src/llama.cpp/tests/test-sampling.cpp +0 -399
- package/src/llama.cpp/tests/test-tokenizer-0.cpp +0 -312
- package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +0 -155
- package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +0 -125
- package/src/llama.cpp/tools/CMakeLists.txt +0 -39
- package/src/llama.cpp/tools/batched-bench/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/batched-bench/batched-bench.cpp +0 -204
- package/src/llama.cpp/tools/cvector-generator/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/cvector-generator/completions.txt +0 -582
- package/src/llama.cpp/tools/cvector-generator/cvector-generator.cpp +0 -508
- package/src/llama.cpp/tools/cvector-generator/mean.hpp +0 -48
- package/src/llama.cpp/tools/cvector-generator/negative.txt +0 -4
- package/src/llama.cpp/tools/cvector-generator/pca.hpp +0 -315
- package/src/llama.cpp/tools/cvector-generator/positive.txt +0 -4
- package/src/llama.cpp/tools/export-lora/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/export-lora/export-lora.cpp +0 -434
- package/src/llama.cpp/tools/gguf-split/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/gguf-split/gguf-split.cpp +0 -583
- package/src/llama.cpp/tools/imatrix/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/imatrix/imatrix.cpp +0 -667
- package/src/llama.cpp/tools/llama-bench/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/llama-bench/llama-bench.cpp +0 -2024
- package/src/llama.cpp/tools/main/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/main/main.cpp +0 -977
- package/src/llama.cpp/tools/mtmd/CMakeLists.txt +0 -58
- package/src/llama.cpp/tools/mtmd/clip-impl.h +0 -462
- package/src/llama.cpp/tools/mtmd/clip.cpp +0 -4024
- package/src/llama.cpp/tools/mtmd/clip.h +0 -101
- package/src/llama.cpp/tools/mtmd/deprecation-warning.cpp +0 -22
- package/src/llama.cpp/tools/mtmd/miniaudio.h +0 -93468
- package/src/llama.cpp/tools/mtmd/mtmd-audio.cpp +0 -855
- package/src/llama.cpp/tools/mtmd/mtmd-audio.h +0 -62
- package/src/llama.cpp/tools/mtmd/mtmd-cli.cpp +0 -377
- package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +0 -297
- package/src/llama.cpp/tools/mtmd/mtmd.cpp +0 -942
- package/src/llama.cpp/tools/mtmd/mtmd.h +0 -362
- package/src/llama.cpp/tools/mtmd/requirements.txt +0 -5
- package/src/llama.cpp/tools/perplexity/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/perplexity/perplexity.cpp +0 -2063
- package/src/llama.cpp/tools/quantize/CMakeLists.txt +0 -6
- package/src/llama.cpp/tools/quantize/quantize.cpp +0 -519
- package/src/llama.cpp/tools/rpc/CMakeLists.txt +0 -4
- package/src/llama.cpp/tools/rpc/rpc-server.cpp +0 -322
- package/src/llama.cpp/tools/run/CMakeLists.txt +0 -16
- package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.cpp +0 -1995
- package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.h +0 -137
- package/src/llama.cpp/tools/run/run.cpp +0 -1261
- package/src/llama.cpp/tools/server/CMakeLists.txt +0 -51
- package/src/llama.cpp/tools/server/bench/requirements.txt +0 -2
- package/src/llama.cpp/tools/server/httplib.h +0 -10506
- package/src/llama.cpp/tools/server/server.cpp +0 -4966
- package/src/llama.cpp/tools/server/tests/requirements.txt +0 -8
- package/src/llama.cpp/tools/server/utils.hpp +0 -1337
- package/src/llama.cpp/tools/tokenize/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/tokenize/tokenize.cpp +0 -416
- package/src/llama.cpp/tools/tts/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/tts/tts.cpp +0 -1092
|
@@ -1,1304 +0,0 @@
|
|
|
1
|
-
#ifdef NDEBUG
|
|
2
|
-
#undef NDEBUG
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
#include "json-schema-to-grammar.h"
|
|
6
|
-
|
|
7
|
-
#include "../src/llama-grammar.h"
|
|
8
|
-
|
|
9
|
-
#include <cassert>
|
|
10
|
-
#include <fstream>
|
|
11
|
-
#include <sstream>
|
|
12
|
-
#include <regex>
|
|
13
|
-
|
|
14
|
-
static std::string trim(const std::string & source) {
|
|
15
|
-
std::string s(source);
|
|
16
|
-
s.erase(0,s.find_first_not_of(" \n\r\t"));
|
|
17
|
-
s.erase(s.find_last_not_of(" \n\r\t")+1);
|
|
18
|
-
return std::regex_replace(s, std::regex("(^|\n)[ \t]+"), "$1");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
enum TestCaseStatus {
|
|
22
|
-
SUCCESS,
|
|
23
|
-
FAILURE
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
struct TestCase {
|
|
27
|
-
TestCaseStatus expected_status;
|
|
28
|
-
std::string name;
|
|
29
|
-
std::string schema;
|
|
30
|
-
std::string expected_grammar;
|
|
31
|
-
|
|
32
|
-
void _print_failure_header() const {
|
|
33
|
-
fprintf(stderr, "#\n# Test '%s' failed.\n#\n%s\n", name.c_str(), schema.c_str());
|
|
34
|
-
}
|
|
35
|
-
void verify(const std::string & actual_grammar) const {
|
|
36
|
-
if (trim(actual_grammar) != trim(expected_grammar)) {
|
|
37
|
-
_print_failure_header();
|
|
38
|
-
fprintf(stderr, "# EXPECTED:\n%s\n# ACTUAL:\n%s\n", expected_grammar.c_str(), actual_grammar.c_str());
|
|
39
|
-
assert(false);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
void verify_expectation_parseable() const {
|
|
43
|
-
try {
|
|
44
|
-
llama_grammar_parser state;
|
|
45
|
-
state.parse(expected_grammar.c_str());
|
|
46
|
-
if (state.symbol_ids.find("root") == state.symbol_ids.end()) {
|
|
47
|
-
throw std::runtime_error("Grammar failed to parse:\n" + expected_grammar);
|
|
48
|
-
}
|
|
49
|
-
} catch (const std::runtime_error & ex) {
|
|
50
|
-
_print_failure_header();
|
|
51
|
-
fprintf(stderr, "# GRAMMAR ERROR: %s\n", ex.what());
|
|
52
|
-
assert(false);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
void verify_status(TestCaseStatus status) const {
|
|
56
|
-
if (status != expected_status) {
|
|
57
|
-
_print_failure_header();
|
|
58
|
-
fprintf(stderr, "# EXPECTED STATUS: %s\n", expected_status == SUCCESS ? "SUCCESS" : "FAILURE");
|
|
59
|
-
fprintf(stderr, "# ACTUAL STATUS: %s\n", status == SUCCESS ? "SUCCESS" : "FAILURE");
|
|
60
|
-
assert(false);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
static void write(const std::string & file, const std::string & content) {
|
|
66
|
-
std::ofstream f;
|
|
67
|
-
f.open(file.c_str());
|
|
68
|
-
f << content.c_str();
|
|
69
|
-
f.close();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static std::string read(const std::string & file) {
|
|
73
|
-
std::ostringstream actuals;
|
|
74
|
-
actuals << std::ifstream(file.c_str()).rdbuf();
|
|
75
|
-
return actuals.str();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static void test_all(const std::string & lang, std::function<void(const TestCase &)> runner) {
|
|
79
|
-
fprintf(stderr, "#\n# Testing JSON schema conversion (%s)\n#\n", lang.c_str());
|
|
80
|
-
auto test = [&](const TestCase & tc) {
|
|
81
|
-
fprintf(stderr, "- %s%s\n", tc.name.c_str(), tc.expected_status == FAILURE ? " (failure expected)" : "");
|
|
82
|
-
runner(tc);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
test({
|
|
86
|
-
SUCCESS,
|
|
87
|
-
"min 0",
|
|
88
|
-
R"""({
|
|
89
|
-
"type": "integer",
|
|
90
|
-
"minimum": 0
|
|
91
|
-
})""",
|
|
92
|
-
R"""(
|
|
93
|
-
root ::= ([0] | [1-9] [0-9]{0,15}) space
|
|
94
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
95
|
-
)"""
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test({
|
|
99
|
-
SUCCESS,
|
|
100
|
-
"min 1",
|
|
101
|
-
R"""({
|
|
102
|
-
"type": "integer",
|
|
103
|
-
"minimum": 1
|
|
104
|
-
})""",
|
|
105
|
-
R"""(
|
|
106
|
-
root ::= ([1-9] [0-9]{0,15}) space
|
|
107
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
108
|
-
)"""
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test({
|
|
112
|
-
SUCCESS,
|
|
113
|
-
"min 3",
|
|
114
|
-
R"""({
|
|
115
|
-
"type": "integer",
|
|
116
|
-
"minimum": 3
|
|
117
|
-
})""",
|
|
118
|
-
R"""(
|
|
119
|
-
root ::= ([1-2] [0-9]{1,15} | [3-9] [0-9]{0,15}) space
|
|
120
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
121
|
-
)"""
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test({
|
|
125
|
-
SUCCESS,
|
|
126
|
-
"min 9",
|
|
127
|
-
R"""({
|
|
128
|
-
"type": "integer",
|
|
129
|
-
"minimum": 9
|
|
130
|
-
})""",
|
|
131
|
-
R"""(
|
|
132
|
-
root ::= ([1-8] [0-9]{1,15} | [9] [0-9]{0,15}) space
|
|
133
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
134
|
-
)"""
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test({
|
|
138
|
-
SUCCESS,
|
|
139
|
-
"min 10",
|
|
140
|
-
R"""({
|
|
141
|
-
"type": "integer",
|
|
142
|
-
"minimum": 10
|
|
143
|
-
})""",
|
|
144
|
-
R"""(
|
|
145
|
-
root ::= ([1] ([0-9]{1,15}) | [2-9] [0-9]{1,15}) space
|
|
146
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
147
|
-
)"""
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test({
|
|
151
|
-
SUCCESS,
|
|
152
|
-
"min 25",
|
|
153
|
-
R"""({
|
|
154
|
-
"type": "integer",
|
|
155
|
-
"minimum": 25
|
|
156
|
-
})""",
|
|
157
|
-
R"""(
|
|
158
|
-
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
|
|
159
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
160
|
-
)"""
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test({
|
|
164
|
-
SUCCESS,
|
|
165
|
-
"max 30",
|
|
166
|
-
R"""({
|
|
167
|
-
"type": "integer",
|
|
168
|
-
"maximum": 30
|
|
169
|
-
})""",
|
|
170
|
-
R"""(
|
|
171
|
-
root ::= ("-" [1-9] [0-9]{0,15} | [0-9] | ([1-2] [0-9] | [3] "0")) space
|
|
172
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
173
|
-
)"""
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test({
|
|
177
|
-
SUCCESS,
|
|
178
|
-
"min -5",
|
|
179
|
-
R"""({
|
|
180
|
-
"type": "integer",
|
|
181
|
-
"minimum": -5
|
|
182
|
-
})""",
|
|
183
|
-
R"""(
|
|
184
|
-
root ::= ("-" ([0-5]) | [0] | [1-9] [0-9]{0,15}) space
|
|
185
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
186
|
-
)"""
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test({
|
|
190
|
-
SUCCESS,
|
|
191
|
-
"min -123",
|
|
192
|
-
R"""({
|
|
193
|
-
"type": "integer",
|
|
194
|
-
"minimum": -123
|
|
195
|
-
})""",
|
|
196
|
-
R"""(
|
|
197
|
-
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
|
|
198
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
199
|
-
)"""
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test({
|
|
203
|
-
SUCCESS,
|
|
204
|
-
"max -5",
|
|
205
|
-
R"""({
|
|
206
|
-
"type": "integer",
|
|
207
|
-
"maximum": -5
|
|
208
|
-
})""",
|
|
209
|
-
R"""(
|
|
210
|
-
root ::= ("-" ([0-4] [0-9]{1,15} | [5-9] [0-9]{0,15})) space
|
|
211
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
212
|
-
)"""
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test({
|
|
216
|
-
SUCCESS,
|
|
217
|
-
"max 1",
|
|
218
|
-
R"""({
|
|
219
|
-
"type": "integer",
|
|
220
|
-
"maximum": 1
|
|
221
|
-
})""",
|
|
222
|
-
R"""(
|
|
223
|
-
root ::= ("-" [1-9] [0-9]{0,15} | [0-1]) space
|
|
224
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
225
|
-
)"""
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test({
|
|
229
|
-
SUCCESS,
|
|
230
|
-
"max 100",
|
|
231
|
-
R"""({
|
|
232
|
-
"type": "integer",
|
|
233
|
-
"maximum": 100
|
|
234
|
-
})""",
|
|
235
|
-
R"""(
|
|
236
|
-
root ::= ("-" [1-9] [0-9]{0,15} | [0-9] | ([1-8] [0-9] | [9] [0-9]) | "100") space
|
|
237
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
238
|
-
)"""
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test({
|
|
242
|
-
SUCCESS,
|
|
243
|
-
"min 0 max 23",
|
|
244
|
-
R"""({
|
|
245
|
-
"type": "integer",
|
|
246
|
-
"minimum": 0,
|
|
247
|
-
"maximum": 23
|
|
248
|
-
})""",
|
|
249
|
-
R"""(
|
|
250
|
-
root ::= ([0-9] | ([1] [0-9] | [2] [0-3])) space
|
|
251
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
252
|
-
)"""
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test({
|
|
256
|
-
SUCCESS,
|
|
257
|
-
"min 15 max 300",
|
|
258
|
-
R"""({
|
|
259
|
-
"type": "integer",
|
|
260
|
-
"minimum": 15,
|
|
261
|
-
"maximum": 300
|
|
262
|
-
})""",
|
|
263
|
-
R"""(
|
|
264
|
-
root ::= (([1] ([5-9]) | [2-9] [0-9]) | ([1-2] [0-9]{2} | [3] "00")) space
|
|
265
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
266
|
-
)"""
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test({
|
|
270
|
-
SUCCESS,
|
|
271
|
-
"min 5 max 30",
|
|
272
|
-
R"""({
|
|
273
|
-
"type": "integer",
|
|
274
|
-
"minimum": 5,
|
|
275
|
-
"maximum": 30
|
|
276
|
-
})""",
|
|
277
|
-
R"""(
|
|
278
|
-
root ::= ([5-9] | ([1-2] [0-9] | [3] "0")) space
|
|
279
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
280
|
-
)"""
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
test({
|
|
284
|
-
SUCCESS,
|
|
285
|
-
"min -123 max 42",
|
|
286
|
-
R"""({
|
|
287
|
-
"type": "integer",
|
|
288
|
-
"minimum": -123,
|
|
289
|
-
"maximum": 42
|
|
290
|
-
})""",
|
|
291
|
-
R"""(
|
|
292
|
-
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
|
|
293
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
294
|
-
)"""
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
test({
|
|
298
|
-
SUCCESS,
|
|
299
|
-
"min -10 max 10",
|
|
300
|
-
R"""({
|
|
301
|
-
"type": "integer",
|
|
302
|
-
"minimum": -10,
|
|
303
|
-
"maximum": 10
|
|
304
|
-
})""",
|
|
305
|
-
R"""(
|
|
306
|
-
root ::= ("-" ([0-9] | "10") | [0-9] | "10") space
|
|
307
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
308
|
-
)"""
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test({
|
|
312
|
-
FAILURE,
|
|
313
|
-
"unknown type",
|
|
314
|
-
R"""({
|
|
315
|
-
"type": "kaboom"
|
|
316
|
-
})""",
|
|
317
|
-
""
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
test({
|
|
321
|
-
FAILURE,
|
|
322
|
-
"invalid type",
|
|
323
|
-
R"""({
|
|
324
|
-
"type": 123
|
|
325
|
-
})""",
|
|
326
|
-
""
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
test({
|
|
330
|
-
SUCCESS,
|
|
331
|
-
"empty schema (object)",
|
|
332
|
-
"{}",
|
|
333
|
-
R"""(
|
|
334
|
-
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
335
|
-
boolean ::= ("true" | "false") space
|
|
336
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
337
|
-
decimal-part ::= [0-9]{1,16}
|
|
338
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
339
|
-
null ::= "null" space
|
|
340
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
341
|
-
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
342
|
-
root ::= object
|
|
343
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
344
|
-
string ::= "\"" char* "\"" space
|
|
345
|
-
value ::= object | array | string | number | boolean | null
|
|
346
|
-
)"""
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
test({
|
|
350
|
-
SUCCESS,
|
|
351
|
-
"exotic formats",
|
|
352
|
-
R"""({
|
|
353
|
-
"items": [
|
|
354
|
-
{ "format": "date" },
|
|
355
|
-
{ "format": "uuid" },
|
|
356
|
-
{ "format": "time" },
|
|
357
|
-
{ "format": "date-time" }
|
|
358
|
-
]
|
|
359
|
-
})""",
|
|
360
|
-
R"""(
|
|
361
|
-
date ::= [0-9]{4} "-" ( "0" [1-9] | "1" [0-2] ) "-" ( "0" [1-9] | [1-2] [0-9] | "3" [0-1] )
|
|
362
|
-
date-string ::= "\"" date "\"" space
|
|
363
|
-
date-time ::= date "T" time
|
|
364
|
-
date-time-string ::= "\"" date-time "\"" space
|
|
365
|
-
root ::= "[" space tuple-0 "," space uuid "," space tuple-2 "," space tuple-3 "]" space
|
|
366
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
367
|
-
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] )
|
|
368
|
-
time-string ::= "\"" time "\"" space
|
|
369
|
-
tuple-0 ::= date-string
|
|
370
|
-
tuple-2 ::= time-string
|
|
371
|
-
tuple-3 ::= date-time-string
|
|
372
|
-
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
|
|
373
|
-
)"""
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
test({
|
|
377
|
-
SUCCESS,
|
|
378
|
-
"string",
|
|
379
|
-
R"""({
|
|
380
|
-
"type": "string"
|
|
381
|
-
})""",
|
|
382
|
-
R"""(
|
|
383
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
384
|
-
root ::= "\"" char* "\"" space
|
|
385
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
386
|
-
)"""
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
test({
|
|
390
|
-
SUCCESS,
|
|
391
|
-
"string w/ min length 1",
|
|
392
|
-
R"""({
|
|
393
|
-
"type": "string",
|
|
394
|
-
"minLength": 1
|
|
395
|
-
})""",
|
|
396
|
-
R"""(
|
|
397
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
398
|
-
root ::= "\"" char+ "\"" space
|
|
399
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
400
|
-
)"""
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
test({
|
|
404
|
-
SUCCESS,
|
|
405
|
-
"string w/ min length 3",
|
|
406
|
-
R"""({
|
|
407
|
-
"type": "string",
|
|
408
|
-
"minLength": 3
|
|
409
|
-
})""",
|
|
410
|
-
R"""(
|
|
411
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
412
|
-
root ::= "\"" char{3,} "\"" space
|
|
413
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
414
|
-
)"""
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
test({
|
|
418
|
-
SUCCESS,
|
|
419
|
-
"string w/ max length",
|
|
420
|
-
R"""({
|
|
421
|
-
"type": "string",
|
|
422
|
-
"maxLength": 3
|
|
423
|
-
})""",
|
|
424
|
-
R"""(
|
|
425
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
426
|
-
root ::= "\"" char{0,3} "\"" space
|
|
427
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
428
|
-
)"""
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
test({
|
|
432
|
-
SUCCESS,
|
|
433
|
-
"string w/ min & max length",
|
|
434
|
-
R"""({
|
|
435
|
-
"type": "string",
|
|
436
|
-
"minLength": 1,
|
|
437
|
-
"maxLength": 4
|
|
438
|
-
})""",
|
|
439
|
-
R"""(
|
|
440
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
441
|
-
root ::= "\"" char{1,4} "\"" space
|
|
442
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
443
|
-
)"""
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
test({
|
|
447
|
-
SUCCESS,
|
|
448
|
-
"boolean",
|
|
449
|
-
R"""({
|
|
450
|
-
"type": "boolean"
|
|
451
|
-
})""",
|
|
452
|
-
R"""(
|
|
453
|
-
root ::= ("true" | "false") space
|
|
454
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
455
|
-
)"""
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
test({
|
|
459
|
-
SUCCESS,
|
|
460
|
-
"integer",
|
|
461
|
-
R"""({
|
|
462
|
-
"type": "integer"
|
|
463
|
-
})""",
|
|
464
|
-
R"""(
|
|
465
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
466
|
-
root ::= ("-"? integral-part) space
|
|
467
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
468
|
-
)"""
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
test({
|
|
472
|
-
SUCCESS,
|
|
473
|
-
"string const",
|
|
474
|
-
R"""({
|
|
475
|
-
"const": "foo"
|
|
476
|
-
})""",
|
|
477
|
-
R"""(
|
|
478
|
-
root ::= "\"foo\"" space
|
|
479
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
480
|
-
)"""
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
test({
|
|
484
|
-
SUCCESS,
|
|
485
|
-
"non-string const",
|
|
486
|
-
R"""({
|
|
487
|
-
"const": 123
|
|
488
|
-
})""",
|
|
489
|
-
R"""(
|
|
490
|
-
root ::= "123" space
|
|
491
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
492
|
-
)"""
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
test({
|
|
496
|
-
SUCCESS,
|
|
497
|
-
"non-string enum",
|
|
498
|
-
R"""({
|
|
499
|
-
"enum": ["red", "amber", "green", null, 42, ["foo"]]
|
|
500
|
-
})""",
|
|
501
|
-
R"""(
|
|
502
|
-
root ::= ("\"red\"" | "\"amber\"" | "\"green\"" | "null" | "42" | "[\"foo\"]") space
|
|
503
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
504
|
-
)"""
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
test({
|
|
508
|
-
SUCCESS,
|
|
509
|
-
"string array",
|
|
510
|
-
R"""({
|
|
511
|
-
"type": "array",
|
|
512
|
-
"prefixItems": { "type": "string" }
|
|
513
|
-
})""",
|
|
514
|
-
R"""(
|
|
515
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
516
|
-
root ::= "[" space (string ("," space string)*)? "]" space
|
|
517
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
518
|
-
string ::= "\"" char* "\"" space
|
|
519
|
-
)"""
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
test({
|
|
523
|
-
SUCCESS,
|
|
524
|
-
"nullable string array",
|
|
525
|
-
R"""({
|
|
526
|
-
"type": ["array", "null"],
|
|
527
|
-
"prefixItems": { "type": "string" }
|
|
528
|
-
})""",
|
|
529
|
-
R"""(
|
|
530
|
-
alternative-0 ::= "[" space (string ("," space string)*)? "]" space
|
|
531
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
532
|
-
null ::= "null" space
|
|
533
|
-
root ::= alternative-0 | null
|
|
534
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
535
|
-
string ::= "\"" char* "\"" space
|
|
536
|
-
)"""
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
test({
|
|
540
|
-
SUCCESS,
|
|
541
|
-
"tuple1",
|
|
542
|
-
R"""({
|
|
543
|
-
"prefixItems": [{ "type": "string" }]
|
|
544
|
-
})""",
|
|
545
|
-
R"""(
|
|
546
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
547
|
-
root ::= "[" space string "]" space
|
|
548
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
549
|
-
string ::= "\"" char* "\"" space
|
|
550
|
-
)"""
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
test({
|
|
554
|
-
SUCCESS,
|
|
555
|
-
"tuple2",
|
|
556
|
-
R"""({
|
|
557
|
-
"prefixItems": [{ "type": "string" }, { "type": "number" }]
|
|
558
|
-
})""",
|
|
559
|
-
R"""(
|
|
560
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
561
|
-
decimal-part ::= [0-9]{1,16}
|
|
562
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
563
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
564
|
-
root ::= "[" space string "," space number "]" space
|
|
565
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
566
|
-
string ::= "\"" char* "\"" space
|
|
567
|
-
)"""
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
test({
|
|
571
|
-
SUCCESS,
|
|
572
|
-
"number",
|
|
573
|
-
R"""({
|
|
574
|
-
"type": "number"
|
|
575
|
-
})""",
|
|
576
|
-
R"""(
|
|
577
|
-
decimal-part ::= [0-9]{1,16}
|
|
578
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
579
|
-
root ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
580
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
581
|
-
)"""
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
test({
|
|
585
|
-
SUCCESS,
|
|
586
|
-
"minItems",
|
|
587
|
-
R"""({
|
|
588
|
-
"items": {
|
|
589
|
-
"type": "boolean"
|
|
590
|
-
},
|
|
591
|
-
"minItems": 2
|
|
592
|
-
})""",
|
|
593
|
-
R"""(
|
|
594
|
-
boolean ::= ("true" | "false") space
|
|
595
|
-
root ::= "[" space boolean ("," space boolean)+ "]" space
|
|
596
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
597
|
-
)"""
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
test({
|
|
601
|
-
SUCCESS,
|
|
602
|
-
"maxItems 0",
|
|
603
|
-
R"""({
|
|
604
|
-
"items": {
|
|
605
|
-
"type": "boolean"
|
|
606
|
-
},
|
|
607
|
-
"maxItems": 0
|
|
608
|
-
})""",
|
|
609
|
-
R"""(
|
|
610
|
-
boolean ::= ("true" | "false") space
|
|
611
|
-
root ::= "[" space "]" space
|
|
612
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
613
|
-
)"""
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
test({
|
|
617
|
-
SUCCESS,
|
|
618
|
-
"maxItems 1",
|
|
619
|
-
R"""({
|
|
620
|
-
"items": {
|
|
621
|
-
"type": "boolean"
|
|
622
|
-
},
|
|
623
|
-
"maxItems": 1
|
|
624
|
-
})""",
|
|
625
|
-
R"""(
|
|
626
|
-
boolean ::= ("true" | "false") space
|
|
627
|
-
root ::= "[" space boolean? "]" space
|
|
628
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
629
|
-
)"""
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
test({
|
|
633
|
-
SUCCESS,
|
|
634
|
-
"maxItems 2",
|
|
635
|
-
R"""({
|
|
636
|
-
"items": {
|
|
637
|
-
"type": "boolean"
|
|
638
|
-
},
|
|
639
|
-
"maxItems": 2
|
|
640
|
-
})""",
|
|
641
|
-
R"""(
|
|
642
|
-
boolean ::= ("true" | "false") space
|
|
643
|
-
root ::= "[" space (boolean ("," space boolean)?)? "]" space
|
|
644
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
645
|
-
)"""
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
test({
|
|
649
|
-
SUCCESS,
|
|
650
|
-
"min + maxItems",
|
|
651
|
-
R"""({
|
|
652
|
-
"items": {
|
|
653
|
-
"type": ["number", "integer"]
|
|
654
|
-
},
|
|
655
|
-
"minItems": 3,
|
|
656
|
-
"maxItems": 5
|
|
657
|
-
})""",
|
|
658
|
-
R"""(
|
|
659
|
-
decimal-part ::= [0-9]{1,16}
|
|
660
|
-
integer ::= ("-"? integral-part) space
|
|
661
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
662
|
-
item ::= number | integer
|
|
663
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
664
|
-
root ::= "[" space item ("," space item){2,4} "]" space
|
|
665
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
666
|
-
)"""
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
test({
|
|
670
|
-
SUCCESS,
|
|
671
|
-
"min + max items with min + max values across zero",
|
|
672
|
-
R"""({
|
|
673
|
-
"items": {
|
|
674
|
-
"type": "integer",
|
|
675
|
-
"minimum": -12,
|
|
676
|
-
"maximum": 207
|
|
677
|
-
},
|
|
678
|
-
"minItems": 3,
|
|
679
|
-
"maxItems": 5
|
|
680
|
-
})""",
|
|
681
|
-
R"""(
|
|
682
|
-
item ::= ("-" ([0-9] | "1" [0-2]) | [0-9] | ([1-8] [0-9] | [9] [0-9]) | ([1] [0-9]{2} | [2] "0" [0-7])) space
|
|
683
|
-
root ::= "[" space item ("," space item){2,4} "]" space
|
|
684
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
685
|
-
)"""
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
test({
|
|
689
|
-
SUCCESS,
|
|
690
|
-
"min + max items with min + max values",
|
|
691
|
-
R"""({
|
|
692
|
-
"items": {
|
|
693
|
-
"type": "integer",
|
|
694
|
-
"minimum": 12,
|
|
695
|
-
"maximum": 207
|
|
696
|
-
},
|
|
697
|
-
"minItems": 3,
|
|
698
|
-
"maxItems": 5
|
|
699
|
-
})""",
|
|
700
|
-
R"""(
|
|
701
|
-
item ::= (([1] ([2-9]) | [2-9] [0-9]) | ([1] [0-9]{2} | [2] "0" [0-7])) space
|
|
702
|
-
root ::= "[" space item ("," space item){2,4} "]" space
|
|
703
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
704
|
-
)"""
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
test({
|
|
708
|
-
SUCCESS,
|
|
709
|
-
"simple regexp",
|
|
710
|
-
R"""({
|
|
711
|
-
"type": "string",
|
|
712
|
-
"pattern": "^abc?d*efg+(hij)?kl$"
|
|
713
|
-
})""",
|
|
714
|
-
R"""(
|
|
715
|
-
root ::= "\"" ("ab" "c"? "d"* "ef" "g"+ ("hij")? "kl") "\"" space
|
|
716
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
717
|
-
)"""
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
test({
|
|
721
|
-
SUCCESS,
|
|
722
|
-
"regexp escapes",
|
|
723
|
-
R"""({
|
|
724
|
-
"type": "string",
|
|
725
|
-
"pattern": "^\\[\\]\\{\\}\\(\\)\\|\\+\\*\\?$"
|
|
726
|
-
})""",
|
|
727
|
-
R"""(
|
|
728
|
-
root ::= "\"" ("[]{}()|+*?") "\"" space
|
|
729
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
730
|
-
)"""
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
test({
|
|
734
|
-
SUCCESS,
|
|
735
|
-
"regexp quote",
|
|
736
|
-
R"""({
|
|
737
|
-
"type": "string",
|
|
738
|
-
"pattern": "^\"$"
|
|
739
|
-
})""",
|
|
740
|
-
R"""(
|
|
741
|
-
root ::= "\"" ("\"") "\"" space
|
|
742
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
743
|
-
)"""
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
test({
|
|
747
|
-
SUCCESS,
|
|
748
|
-
"regexp with top-level alternation",
|
|
749
|
-
R"""({
|
|
750
|
-
"type": "string",
|
|
751
|
-
"pattern": "^A|B|C|D$"
|
|
752
|
-
})""",
|
|
753
|
-
R"""(
|
|
754
|
-
root ::= "\"" ("A" | "B" | "C" | "D") "\"" space
|
|
755
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
756
|
-
)"""
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
test({
|
|
760
|
-
SUCCESS,
|
|
761
|
-
"regexp",
|
|
762
|
-
R"""({
|
|
763
|
-
"type": "string",
|
|
764
|
-
"pattern": "^(\\([0-9]{1,3}\\))?[0-9]{3}-[0-9]{4} a{3,5}nd...$"
|
|
765
|
-
})""",
|
|
766
|
-
R"""(
|
|
767
|
-
dot ::= [^\x0A\x0D]
|
|
768
|
-
root ::= "\"" (("(" root-1{1,3} ")")? root-1{3,3} "-" root-1{4,4} " " "a"{3,5} "nd" dot dot dot) "\"" space
|
|
769
|
-
root-1 ::= [0-9]
|
|
770
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
771
|
-
)"""
|
|
772
|
-
});
|
|
773
|
-
|
|
774
|
-
test({
|
|
775
|
-
SUCCESS,
|
|
776
|
-
"required props in original order",
|
|
777
|
-
R"""({
|
|
778
|
-
"type": "object",
|
|
779
|
-
"properties": {
|
|
780
|
-
"b": {"type": "string"},
|
|
781
|
-
"c": {"type": "string"},
|
|
782
|
-
"a": {"type": "string"}
|
|
783
|
-
},
|
|
784
|
-
"required": [
|
|
785
|
-
"a",
|
|
786
|
-
"b",
|
|
787
|
-
"c"
|
|
788
|
-
],
|
|
789
|
-
"additionalProperties": false,
|
|
790
|
-
"definitions": {}
|
|
791
|
-
})""",
|
|
792
|
-
R"""(
|
|
793
|
-
a-kv ::= "\"a\"" space ":" space string
|
|
794
|
-
b-kv ::= "\"b\"" space ":" space string
|
|
795
|
-
c-kv ::= "\"c\"" space ":" space string
|
|
796
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
797
|
-
root ::= "{" space b-kv "," space c-kv "," space a-kv "}" space
|
|
798
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
799
|
-
string ::= "\"" char* "\"" space
|
|
800
|
-
)"""
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
test({
|
|
804
|
-
SUCCESS,
|
|
805
|
-
"1 optional prop",
|
|
806
|
-
R"""({
|
|
807
|
-
"properties": {
|
|
808
|
-
"a": {
|
|
809
|
-
"type": "string"
|
|
810
|
-
}
|
|
811
|
-
},
|
|
812
|
-
"additionalProperties": false
|
|
813
|
-
})""",
|
|
814
|
-
R"""(
|
|
815
|
-
a-kv ::= "\"a\"" space ":" space string
|
|
816
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
817
|
-
root ::= "{" space (a-kv )? "}" space
|
|
818
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
819
|
-
string ::= "\"" char* "\"" space
|
|
820
|
-
)"""
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
test({
|
|
824
|
-
SUCCESS,
|
|
825
|
-
"N optional props",
|
|
826
|
-
R"""({
|
|
827
|
-
"properties": {
|
|
828
|
-
"a": {"type": "string"},
|
|
829
|
-
"b": {"type": "string"},
|
|
830
|
-
"c": {"type": "string"}
|
|
831
|
-
},
|
|
832
|
-
"additionalProperties": false
|
|
833
|
-
})""",
|
|
834
|
-
R"""(
|
|
835
|
-
a-kv ::= "\"a\"" space ":" space string
|
|
836
|
-
a-rest ::= ( "," space b-kv )? b-rest
|
|
837
|
-
b-kv ::= "\"b\"" space ":" space string
|
|
838
|
-
b-rest ::= ( "," space c-kv )?
|
|
839
|
-
c-kv ::= "\"c\"" space ":" space string
|
|
840
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
841
|
-
root ::= "{" space (a-kv a-rest | b-kv b-rest | c-kv )? "}" space
|
|
842
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
843
|
-
string ::= "\"" char* "\"" space
|
|
844
|
-
)"""
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
test({
|
|
848
|
-
SUCCESS,
|
|
849
|
-
"required + optional props each in original order",
|
|
850
|
-
R"""({
|
|
851
|
-
"properties": {
|
|
852
|
-
"b": {"type": "string"},
|
|
853
|
-
"a": {"type": "string"},
|
|
854
|
-
"d": {"type": "string"},
|
|
855
|
-
"c": {"type": "string"}
|
|
856
|
-
},
|
|
857
|
-
"required": ["a", "b"],
|
|
858
|
-
"additionalProperties": false
|
|
859
|
-
})""",
|
|
860
|
-
R"""(
|
|
861
|
-
a-kv ::= "\"a\"" space ":" space string
|
|
862
|
-
b-kv ::= "\"b\"" space ":" space string
|
|
863
|
-
c-kv ::= "\"c\"" space ":" space string
|
|
864
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
865
|
-
d-kv ::= "\"d\"" space ":" space string
|
|
866
|
-
d-rest ::= ( "," space c-kv )?
|
|
867
|
-
root ::= "{" space b-kv "," space a-kv ( "," space ( d-kv d-rest | c-kv ) )? "}" space
|
|
868
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
869
|
-
string ::= "\"" char* "\"" space
|
|
870
|
-
)"""
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
test({
|
|
874
|
-
SUCCESS,
|
|
875
|
-
"additional props",
|
|
876
|
-
R"""({
|
|
877
|
-
"type": "object",
|
|
878
|
-
"additionalProperties": {"type": "array", "items": {"type": "number"}}
|
|
879
|
-
})""",
|
|
880
|
-
R"""(
|
|
881
|
-
additional-kv ::= string ":" space additional-value
|
|
882
|
-
additional-value ::= "[" space (number ("," space number)*)? "]" space
|
|
883
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
884
|
-
decimal-part ::= [0-9]{1,16}
|
|
885
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
886
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
887
|
-
root ::= "{" space (additional-kv ( "," space additional-kv )* )? "}" space
|
|
888
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
889
|
-
string ::= "\"" char* "\"" space
|
|
890
|
-
)"""
|
|
891
|
-
});
|
|
892
|
-
|
|
893
|
-
test({
|
|
894
|
-
SUCCESS,
|
|
895
|
-
"additional props (true)",
|
|
896
|
-
R"""({
|
|
897
|
-
"type": "object",
|
|
898
|
-
"additionalProperties": true
|
|
899
|
-
})""",
|
|
900
|
-
R"""(
|
|
901
|
-
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
902
|
-
boolean ::= ("true" | "false") space
|
|
903
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
904
|
-
decimal-part ::= [0-9]{1,16}
|
|
905
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
906
|
-
null ::= "null" space
|
|
907
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
908
|
-
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
909
|
-
root ::= object
|
|
910
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
911
|
-
string ::= "\"" char* "\"" space
|
|
912
|
-
value ::= object | array | string | number | boolean | null
|
|
913
|
-
)"""
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
test({
|
|
917
|
-
SUCCESS,
|
|
918
|
-
"additional props (implicit)",
|
|
919
|
-
R"""({
|
|
920
|
-
"type": "object"
|
|
921
|
-
})""",
|
|
922
|
-
R"""(
|
|
923
|
-
array ::= "[" space ( value ("," space value)* )? "]" space
|
|
924
|
-
boolean ::= ("true" | "false") space
|
|
925
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
926
|
-
decimal-part ::= [0-9]{1,16}
|
|
927
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
928
|
-
null ::= "null" space
|
|
929
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
930
|
-
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
|
|
931
|
-
root ::= object
|
|
932
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
933
|
-
string ::= "\"" char* "\"" space
|
|
934
|
-
value ::= object | array | string | number | boolean | null
|
|
935
|
-
)"""
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
test({
|
|
939
|
-
SUCCESS,
|
|
940
|
-
"empty w/o additional props",
|
|
941
|
-
R"""({
|
|
942
|
-
"type": "object",
|
|
943
|
-
"additionalProperties": false
|
|
944
|
-
})""",
|
|
945
|
-
R"""(
|
|
946
|
-
root ::= "{" space "}" space
|
|
947
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
948
|
-
)"""
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
test({
|
|
952
|
-
SUCCESS,
|
|
953
|
-
"required + additional props",
|
|
954
|
-
R"""({
|
|
955
|
-
"type": "object",
|
|
956
|
-
"properties": {
|
|
957
|
-
"a": {"type": "number"}
|
|
958
|
-
},
|
|
959
|
-
"required": ["a"],
|
|
960
|
-
"additionalProperties": {"type": "string"}
|
|
961
|
-
})""",
|
|
962
|
-
R"""(
|
|
963
|
-
a-kv ::= "\"a\"" space ":" space number
|
|
964
|
-
additional-k ::= ["] ( [a] char+ | [^"a] char* )? ["] space
|
|
965
|
-
additional-kv ::= additional-k ":" space string
|
|
966
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
967
|
-
decimal-part ::= [0-9]{1,16}
|
|
968
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
969
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
970
|
-
root ::= "{" space a-kv ( "," space ( additional-kv ( "," space additional-kv )* ) )? "}" space
|
|
971
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
972
|
-
string ::= "\"" char* "\"" space
|
|
973
|
-
)"""
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
test({
|
|
977
|
-
SUCCESS,
|
|
978
|
-
"optional + additional props",
|
|
979
|
-
R"""({
|
|
980
|
-
"type": "object",
|
|
981
|
-
"properties": {
|
|
982
|
-
"a": {"type": "number"}
|
|
983
|
-
},
|
|
984
|
-
"additionalProperties": {"type": "number"}
|
|
985
|
-
})""",
|
|
986
|
-
R"""(
|
|
987
|
-
a-kv ::= "\"a\"" space ":" space number
|
|
988
|
-
a-rest ::= ( "," space additional-kv )*
|
|
989
|
-
additional-k ::= ["] ( [a] char+ | [^"a] char* )? ["] space
|
|
990
|
-
additional-kv ::= additional-k ":" space number
|
|
991
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
992
|
-
decimal-part ::= [0-9]{1,16}
|
|
993
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
994
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
995
|
-
root ::= "{" space (a-kv a-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
996
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
997
|
-
)"""
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
test({
|
|
1001
|
-
SUCCESS,
|
|
1002
|
-
"required + optional + additional props",
|
|
1003
|
-
R"""({
|
|
1004
|
-
"type": "object",
|
|
1005
|
-
"properties": {
|
|
1006
|
-
"and": {"type": "number"},
|
|
1007
|
-
"also": {"type": "number"}
|
|
1008
|
-
},
|
|
1009
|
-
"required": ["and"],
|
|
1010
|
-
"additionalProperties": {"type": "number"}
|
|
1011
|
-
})""",
|
|
1012
|
-
R"""(
|
|
1013
|
-
additional-k ::= ["] ( [a] ([l] ([s] ([o] char+ | [^"o] char*) | [^"s] char*) | [n] ([d] char+ | [^"d] char*) | [^"ln] char*) | [^"a] char* )? ["] space
|
|
1014
|
-
additional-kv ::= additional-k ":" space number
|
|
1015
|
-
also-kv ::= "\"also\"" space ":" space number
|
|
1016
|
-
also-rest ::= ( "," space additional-kv )*
|
|
1017
|
-
and-kv ::= "\"and\"" space ":" space number
|
|
1018
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1019
|
-
decimal-part ::= [0-9]{1,16}
|
|
1020
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1021
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
1022
|
-
root ::= "{" space and-kv ( "," space ( also-kv also-rest | additional-kv ( "," space additional-kv )* ) )? "}" space
|
|
1023
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1024
|
-
)"""
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
|
-
test({
|
|
1028
|
-
SUCCESS,
|
|
1029
|
-
"optional props with empty name",
|
|
1030
|
-
R"""({
|
|
1031
|
-
"properties": {
|
|
1032
|
-
"": {"type": "integer"},
|
|
1033
|
-
"a": {"type": "integer"}
|
|
1034
|
-
},
|
|
1035
|
-
"additionalProperties": {"type": "integer"}
|
|
1036
|
-
})""",
|
|
1037
|
-
R"""(
|
|
1038
|
-
-kv ::= "\"\"" space ":" space root
|
|
1039
|
-
-rest ::= ( "," space a-kv )? a-rest
|
|
1040
|
-
a-kv ::= "\"a\"" space ":" space integer
|
|
1041
|
-
a-rest ::= ( "," space additional-kv )*
|
|
1042
|
-
additional-k ::= ["] ( [a] char+ | [^"a] char* ) ["] space
|
|
1043
|
-
additional-kv ::= additional-k ":" space integer
|
|
1044
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1045
|
-
integer ::= ("-"? integral-part) space
|
|
1046
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1047
|
-
root ::= ("-"? integral-part) space
|
|
1048
|
-
root0 ::= "{" space (-kv -rest | a-kv a-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1049
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1050
|
-
)"""
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
test({
|
|
1054
|
-
SUCCESS,
|
|
1055
|
-
"optional props with nested names",
|
|
1056
|
-
R"""({
|
|
1057
|
-
"properties": {
|
|
1058
|
-
"a": {"type": "integer"},
|
|
1059
|
-
"aa": {"type": "integer"}
|
|
1060
|
-
},
|
|
1061
|
-
"additionalProperties": {"type": "integer"}
|
|
1062
|
-
})""",
|
|
1063
|
-
R"""(
|
|
1064
|
-
a-kv ::= "\"a\"" space ":" space integer
|
|
1065
|
-
a-rest ::= ( "," space aa-kv )? aa-rest
|
|
1066
|
-
aa-kv ::= "\"aa\"" space ":" space integer
|
|
1067
|
-
aa-rest ::= ( "," space additional-kv )*
|
|
1068
|
-
additional-k ::= ["] ( [a] ([a] char+ | [^"a] char*) | [^"a] char* )? ["] space
|
|
1069
|
-
additional-kv ::= additional-k ":" space integer
|
|
1070
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1071
|
-
integer ::= ("-"? integral-part) space
|
|
1072
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1073
|
-
root ::= "{" space (a-kv a-rest | aa-kv aa-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1074
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1075
|
-
)"""
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
|
-
test({
|
|
1079
|
-
SUCCESS,
|
|
1080
|
-
"optional props with common prefix",
|
|
1081
|
-
R"""({
|
|
1082
|
-
"properties": {
|
|
1083
|
-
"ab": {"type": "integer"},
|
|
1084
|
-
"ac": {"type": "integer"}
|
|
1085
|
-
},
|
|
1086
|
-
"additionalProperties": {"type": "integer"}
|
|
1087
|
-
})""",
|
|
1088
|
-
R"""(
|
|
1089
|
-
ab-kv ::= "\"ab\"" space ":" space integer
|
|
1090
|
-
ab-rest ::= ( "," space ac-kv )? ac-rest
|
|
1091
|
-
ac-kv ::= "\"ac\"" space ":" space integer
|
|
1092
|
-
ac-rest ::= ( "," space additional-kv )*
|
|
1093
|
-
additional-k ::= ["] ( [a] ([b] char+ | [c] char+ | [^"bc] char*) | [^"a] char* )? ["] space
|
|
1094
|
-
additional-kv ::= additional-k ":" space integer
|
|
1095
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1096
|
-
integer ::= ("-"? integral-part) space
|
|
1097
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1098
|
-
root ::= "{" space (ab-kv ab-rest | ac-kv ac-rest | additional-kv ( "," space additional-kv )* )? "}" space
|
|
1099
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1100
|
-
)"""
|
|
1101
|
-
});
|
|
1102
|
-
|
|
1103
|
-
test({
|
|
1104
|
-
SUCCESS,
|
|
1105
|
-
"top-level $ref",
|
|
1106
|
-
R"""({
|
|
1107
|
-
"$ref": "#/definitions/foo",
|
|
1108
|
-
"definitions": {
|
|
1109
|
-
"foo": {
|
|
1110
|
-
"type": "object",
|
|
1111
|
-
"properties": {
|
|
1112
|
-
"a": {
|
|
1113
|
-
"type": "string"
|
|
1114
|
-
}
|
|
1115
|
-
},
|
|
1116
|
-
"required": [
|
|
1117
|
-
"a"
|
|
1118
|
-
],
|
|
1119
|
-
"additionalProperties": false
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
})""",
|
|
1123
|
-
R"""(
|
|
1124
|
-
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
|
|
1125
|
-
foo ::= "{" space foo-a-kv "}" space
|
|
1126
|
-
foo-a-kv ::= "\"a\"" space ":" space string
|
|
1127
|
-
root ::= foo
|
|
1128
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1129
|
-
string ::= "\"" char* "\"" space
|
|
1130
|
-
)"""
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
test({
|
|
1134
|
-
SUCCESS,
|
|
1135
|
-
"anyOf",
|
|
1136
|
-
R"""({
|
|
1137
|
-
"anyOf": [
|
|
1138
|
-
{"$ref": "#/definitions/foo"},
|
|
1139
|
-
{"$ref": "#/definitions/bar"}
|
|
1140
|
-
],
|
|
1141
|
-
"definitions": {
|
|
1142
|
-
"foo": {
|
|
1143
|
-
"properties": {"a": {"type": "number"}}
|
|
1144
|
-
},
|
|
1145
|
-
"bar": {
|
|
1146
|
-
"properties": {"b": {"type": "number"}}
|
|
1147
|
-
}
|
|
1148
|
-
},
|
|
1149
|
-
"type": "object"
|
|
1150
|
-
})""",
|
|
1151
|
-
R"""(
|
|
1152
|
-
alternative-0 ::= foo
|
|
1153
|
-
alternative-1 ::= bar
|
|
1154
|
-
bar ::= "{" space (bar-b-kv )? "}" space
|
|
1155
|
-
bar-b-kv ::= "\"b\"" space ":" space number
|
|
1156
|
-
decimal-part ::= [0-9]{1,16}
|
|
1157
|
-
foo ::= "{" space (foo-a-kv )? "}" space
|
|
1158
|
-
foo-a-kv ::= "\"a\"" space ":" space number
|
|
1159
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1160
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
1161
|
-
root ::= alternative-0 | alternative-1
|
|
1162
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1163
|
-
)"""
|
|
1164
|
-
});
|
|
1165
|
-
|
|
1166
|
-
test({
|
|
1167
|
-
SUCCESS,
|
|
1168
|
-
"mix of allOf, anyOf and $ref (similar to https://json.schemastore.org/tsconfig.json)",
|
|
1169
|
-
R"""({
|
|
1170
|
-
"allOf": [
|
|
1171
|
-
{"$ref": "#/definitions/foo"},
|
|
1172
|
-
{"$ref": "#/definitions/bar"},
|
|
1173
|
-
{
|
|
1174
|
-
"anyOf": [
|
|
1175
|
-
{"$ref": "#/definitions/baz"},
|
|
1176
|
-
{"$ref": "#/definitions/bam"}
|
|
1177
|
-
]
|
|
1178
|
-
}
|
|
1179
|
-
],
|
|
1180
|
-
"definitions": {
|
|
1181
|
-
"foo": {
|
|
1182
|
-
"properties": {"a": {"type": "number"}}
|
|
1183
|
-
},
|
|
1184
|
-
"bar": {
|
|
1185
|
-
"properties": {"b": {"type": "number"}}
|
|
1186
|
-
},
|
|
1187
|
-
"bam": {
|
|
1188
|
-
"properties": {"c": {"type": "number"}}
|
|
1189
|
-
},
|
|
1190
|
-
"baz": {
|
|
1191
|
-
"properties": {"d": {"type": "number"}}
|
|
1192
|
-
}
|
|
1193
|
-
},
|
|
1194
|
-
"type": "object"
|
|
1195
|
-
})""",
|
|
1196
|
-
R"""(
|
|
1197
|
-
a-kv ::= "\"a\"" space ":" space number
|
|
1198
|
-
b-kv ::= "\"b\"" space ":" space number
|
|
1199
|
-
c-kv ::= "\"c\"" space ":" space number
|
|
1200
|
-
d-kv ::= "\"d\"" space ":" space number
|
|
1201
|
-
d-rest ::= ( "," space c-kv )?
|
|
1202
|
-
decimal-part ::= [0-9]{1,16}
|
|
1203
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1204
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
1205
|
-
root ::= "{" space a-kv "," space b-kv ( "," space ( d-kv d-rest | c-kv ) )? "}" space
|
|
1206
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1207
|
-
)"""
|
|
1208
|
-
});
|
|
1209
|
-
|
|
1210
|
-
test({
|
|
1211
|
-
SUCCESS,
|
|
1212
|
-
"conflicting names",
|
|
1213
|
-
R"""({
|
|
1214
|
-
"type": "object",
|
|
1215
|
-
"properties": {
|
|
1216
|
-
"number": {
|
|
1217
|
-
"type": "object",
|
|
1218
|
-
"properties": {
|
|
1219
|
-
"number": {
|
|
1220
|
-
"type": "object",
|
|
1221
|
-
"properties": {
|
|
1222
|
-
"root": {
|
|
1223
|
-
"type": "number"
|
|
1224
|
-
}
|
|
1225
|
-
},
|
|
1226
|
-
"required": [
|
|
1227
|
-
"root"
|
|
1228
|
-
],
|
|
1229
|
-
"additionalProperties": false
|
|
1230
|
-
}
|
|
1231
|
-
},
|
|
1232
|
-
"required": [
|
|
1233
|
-
"number"
|
|
1234
|
-
],
|
|
1235
|
-
"additionalProperties": false
|
|
1236
|
-
}
|
|
1237
|
-
},
|
|
1238
|
-
"required": [
|
|
1239
|
-
"number"
|
|
1240
|
-
],
|
|
1241
|
-
"additionalProperties": false,
|
|
1242
|
-
"definitions": {}
|
|
1243
|
-
})""",
|
|
1244
|
-
R"""(
|
|
1245
|
-
decimal-part ::= [0-9]{1,16}
|
|
1246
|
-
integral-part ::= [0] | [1-9] [0-9]{0,15}
|
|
1247
|
-
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
|
|
1248
|
-
number- ::= "{" space number-number-kv "}" space
|
|
1249
|
-
number-kv ::= "\"number\"" space ":" space number-
|
|
1250
|
-
number-number ::= "{" space number-number-root-kv "}" space
|
|
1251
|
-
number-number-kv ::= "\"number\"" space ":" space number-number
|
|
1252
|
-
number-number-root-kv ::= "\"root\"" space ":" space number
|
|
1253
|
-
root ::= "{" space number-kv "}" space
|
|
1254
|
-
space ::= | " " | "\n"{1,2} [ \t]{0,20}
|
|
1255
|
-
)"""
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
int main() {
|
|
1260
|
-
fprintf(stderr, "LLAMA_NODE_AVAILABLE = %s\n", getenv("LLAMA_NODE_AVAILABLE") ? "true" : "false");
|
|
1261
|
-
fprintf(stderr, "LLAMA_PYTHON_AVAILABLE = %s\n", getenv("LLAMA_PYTHON_AVAILABLE") ? "true" : "false");
|
|
1262
|
-
|
|
1263
|
-
test_all("C++", [](const TestCase & tc) {
|
|
1264
|
-
try {
|
|
1265
|
-
tc.verify(json_schema_to_grammar(nlohmann::ordered_json::parse(tc.schema), true));
|
|
1266
|
-
tc.verify_status(SUCCESS);
|
|
1267
|
-
} catch (const std::runtime_error & ex) {
|
|
1268
|
-
fprintf(stderr, "Error: %s\n", ex.what());
|
|
1269
|
-
tc.verify_status(FAILURE);
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
|
|
1273
|
-
if (getenv("LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR")) {
|
|
1274
|
-
fprintf(stderr, "\033[33mWARNING: Skipping slow tests on emulator.\n\033[0m");
|
|
1275
|
-
} else {
|
|
1276
|
-
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)) {
|
|
1277
|
-
test_all("Python", [](const TestCase & tc) {
|
|
1278
|
-
write("test-json-schema-input.tmp", tc.schema);
|
|
1279
|
-
tc.verify_status(std::system(
|
|
1280
|
-
"python ./examples/json_schema_to_grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
|
1281
|
-
tc.verify(read("test-grammar-output.tmp"));
|
|
1282
|
-
});
|
|
1283
|
-
} else {
|
|
1284
|
-
fprintf(stderr, "\033[33mWARNING: Python not found (min version required is 3.8), skipping Python JSON schema -> grammar tests.\n\033[0m");
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
if (getenv("LLAMA_NODE_AVAILABLE") || (std::system("node --version") == 0)) {
|
|
1288
|
-
test_all("JavaScript", [](const TestCase & tc) {
|
|
1289
|
-
write("test-json-schema-input.tmp", tc.schema);
|
|
1290
|
-
tc.verify_status(std::system(
|
|
1291
|
-
"node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
|
1292
|
-
tc.verify(read("test-grammar-output.tmp"));
|
|
1293
|
-
});
|
|
1294
|
-
} else {
|
|
1295
|
-
fprintf(stderr, "\033[33mWARNING: Node not found, skipping JavaScript JSON schema -> grammar tests.\n\033[0m");
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
test_all("Check Expectations Validity", [](const TestCase & tc) {
|
|
1300
|
-
if (tc.expected_status == SUCCESS) {
|
|
1301
|
-
tc.verify_expectation_parseable();
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
}
|