diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb3687e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/tests/cache +/tree-sitter/src +/tree-sitter/node_modules diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9b0bf68 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +image: "rust:latest" + +fmt: + before_script: + - rustup component add rustfmt + script: + - cargo fmt --check + +clippy: + before_script: + - apt-get update -yqq + - apt-get install clang nodejs -yqq + - rustup component add clippy + script: + - cargo clippy --all-targets --all-features + +clippy_msrv: + before_script: + - apt-get update -yqq + - apt-get install clang nodejs -yqq + - rustup override set 1.65.0 + - rustup component add clippy + script: + - cargo clippy --all-targets --all-features -- -D warnings -D clippy::all + +test: + before_script: + - apt-get update -yqq + - apt-get install clang nodejs -yqq + - rustup component add clippy + script: + - cargo test + cache: + key: w3c-testsuite + paths: + - tests/cache + +python: + before_script: + - apt-get update -yqq + - apt-get install clang nodejs python3-pip -yqq + script: + - pip install . + - turtlefmt --check tests/to.simple.ttl diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1b2504d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2272 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bindgen" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cc" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "winapi", +] + +[[package]] +name = "chunked_transfer" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cca491388666e04d7248af3f60f0c40cfb0991c72205595d7c396e3510207d1a" + +[[package]] +name = "clang-sys" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "clap" +version = "4.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim 0.10.0", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cxx" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "diffy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e616e59155c92257e84970156f506287853355f58cd4a6eb167385722c32b790" +dependencies = [ + "nu-ansi-term", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "html-escape" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +dependencies = [ + "utf8-width", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "ipnet" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e" + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys 0.42.0", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "jobserver" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "json-event-parser" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f12e624eaeb74accb9bb48f01cb071427f68115aaafa5689acb372d7e22977" + +[[package]] +name = "lasso" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb7b21a526375c5ca55f1a6dfd4e1fad9fa4edd750f530252a718a44b2608f0" +dependencies = [ + "hashbrown 0.11.2", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "7.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "ntapi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc" +dependencies = [ + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "oxigraph" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "babc4af57781e6677fd7c7f0d1942a4d12f162e1c72bf3b894916844f8ab33b8" +dependencies = [ + "digest", + "getrandom", + "hex", + "js-sys", + "lazy_static", + "libc", + "md-5", + "nom", + "oxilangtag", + "oxiri", + "oxrdf", + "oxrocksdb-sys", + "rand", + "regex", + "rio_api", + "rio_turtle", + "rio_xml", + "sha-1", + "sha2", + "siphasher", + "sparesults", + "spargebra", + "sysinfo", +] + +[[package]] +name = "oxilangtag" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d91edf4fbb970279443471345a4e8c491bf05bb283b3e6c88e4e606fd8c181b" + +[[package]] +name = "oxiri" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb175ec8981211357b7b379869c2f8d555881c55ea62311428ec0de46d89bd5c" + +[[package]] +name = "oxrdf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb4aabe9b87e1e8c7a0d5973ee5a009141c211021c68c5d15eb75b7a0d97e669" +dependencies = [ + "lasso", + "oxilangtag", + "oxiri", + "rand", +] + +[[package]] +name = "oxrocksdb-sys" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5627401751d220c080a2110ceb8ecb2d41edc689cd63cc4ec916e1235a7bd510" +dependencies = [ + "bindgen", + "cc", + "libc", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "peg" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a07f2cafdc3babeebc087e499118343442b742cc7c31b4d054682cc598508554" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a90084dc05cf0428428e3d12399f39faad19b0909f64fb9170c9fdd6d9cd49b" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa00462b37ead6d11a82c9d568b26682d78e0477dc02d1966c013af80969739" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rio_api" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bce58dd4aed6d706bd628c24076d9e88f6a8dd90a75fd0627b7440044b5975" + +[[package]] +name = "rio_turtle" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02aa66357f0ae6e1c5fb269a6823e588a51d191cc246c6b6c6bb9620cbe3e46e" +dependencies = [ + "oxilangtag", + "oxiri", + "rio_api", +] + +[[package]] +name = "rio_xml" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4751b8bed0b6e1ede898341476ef6829f4046065781bf43e8481bc00cb5e943" +dependencies = [ + "oxilangtag", + "oxiri", + "quick-xml", + "rio_api", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallbitvec" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75ce4f9dc4a41b4c3476cc925f1efb11b66df373a8fde5d4b8915fa91b5d995e" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "sparesults" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15891fa3f6a30194898da4ec9d2a9f56c93fab98d6b48936a36f7c0ce6045e8f" +dependencies = [ + "json-event-parser", + "oxrdf", + "quick-xml", +] + +[[package]] +name = "spargebra" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f59344d626753e9798069fed140ee558a9cd7ffad7a0dfdac446c2b41e2a0cd4" +dependencies = [ + "oxilangtag", + "oxiri", + "oxrdf", + "peg", + "rand", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sysinfo" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17351d0e9eb8841897b14e9669378f3c69fb57779cc04f8ca9a9d512edfb2563" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tiny_http" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce51b50006056f590c9b7c3808c3bd70f0d1101666629713866c227d6e58d39" +dependencies = [ + "ascii", + "chrono", + "chunked_transfer", + "log", + "url", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tree-sitter" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4423c784fe11398ca91e505cdc71356b07b1a924fc8735cfab5333afe3e18bc" +dependencies = [ + "cc", + "regex", +] + +[[package]] +name = "tree-sitter-cli" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9992c51467921e082231e5b22a17bc29f26e9df9eac1beb87d73836c3e06bfc2" +dependencies = [ + "ansi_term", + "anyhow", + "atty", + "clap 2.34.0", + "difference", + "dirs", + "glob", + "html-escape", + "indexmap", + "lazy_static", + "log", + "regex", + "regex-syntax", + "rustc-hash", + "semver", + "serde", + "serde_json", + "smallbitvec", + "tiny_http", + "toml", + "tree-sitter", + "tree-sitter-config", + "tree-sitter-highlight", + "tree-sitter-loader", + "tree-sitter-tags", + "walkdir", + "webbrowser", + "which", +] + +[[package]] +name = "tree-sitter-config" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5fec4cb27f052ead2246631b332dba0cb6af9a54ce012badee59c4b0ded5e03" +dependencies = [ + "anyhow", + "dirs", + "serde", + "serde_json", +] + +[[package]] +name = "tree-sitter-highlight" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "042342584c5a7a0b833d9fc4e2bdab3f9868ddc6c4b339a1e01451c6720868bc" +dependencies = [ + "regex", + "thiserror", + "tree-sitter", +] + +[[package]] +name = "tree-sitter-loader" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b17eef4833c7c139abed66d562dfa23228e97e647597baf246fd56c21bbfaf" +dependencies = [ + "anyhow", + "cc", + "dirs", + "libloading", + "once_cell", + "regex", + "serde", + "serde_json", + "tree-sitter", + "tree-sitter-highlight", + "tree-sitter-tags", +] + +[[package]] +name = "tree-sitter-tags" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb3f1376219530a37a809751ecf65aa35fd8b9c1c4ab6d4faf5f6a9eeda2c05" +dependencies = [ + "memchr", + "regex", + "thiserror", + "tree-sitter", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "turtlefmt" +version = "0.1.0" +dependencies = [ + "anyhow", + "cc", + "clap 4.0.32", + "diffy", + "oxigraph", + "reqwest", + "tree-sitter", + "tree-sitter-cli", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a" +dependencies = [ + "web-sys", + "widestring", + "winapi", +] + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b1dd325 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,27 @@ +[package] +authors = ["Tpt "] +description = "Auto-formatter for RDF Turtle" +build = "build.rs" +edition = "2021" +keywords = ["Turtle"] +license = "Apache-2.0" +name = "turtlefmt" +readme = "README.md" +repository = "https://gitlab.com/helsing/turtlefmt" +rust-version = "1.65.0" +version = "0.1.0" + +[dependencies] +anyhow = "1" +clap = { version = "4", features = ["derive"] } +diffy = "0.3" +tree-sitter = "0.20" + +[dev-dependencies] +reqwest = { version = "0.11", features = ["blocking"] } +oxigraph = "0.3" # TODO: use only oxrdf and the parsers +tree-sitter-cli = "0.20" + +[build-dependencies] +cc = "1.0" +tree-sitter-cli = "0.20" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 8e7e699..0ab76b4 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,72 @@ -# turtlefmt +# TurtleFmt +`turtlefmt` is an auto formatter for [RDF Turtle](https://www.w3.org/TR/turtle/) under Apache 2 license. -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/helsing/turtlefmt.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/helsing/turtlefmt/-/settings/integrations) +## Installation -## Collaborate with your team +It is currently distributed on: +- [Crates.io](https://crates.io/crates/turtlefmt): `cargo install turtlefmt` +- [Pypi](https://pypi.org/project/turtlefmt): `pipx install turtlefmt` -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +Build from source requires NodeJS 6.0+ to be available in your `PATH`. -## Test and Deploy -Use the built-in continuous integration in GitLab. +## Usage -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +To use it: -*** +```sh +turtlefmt MY_TURTLE_FILE.ttl +``` -# Editing this README +It is also possible to check if formatting of a given file is valid according to the formatter using: -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +```sh +turtlefmt --check MY_TURTLE_FILE.ttl +``` -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +If the formatting is not valid, a patch to properly format the file is written to the standard output. -## Name -Choose a self-explaining name for your project. +It is also possible to check a complete directory (and its subdirectories): -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. +```sh +turtlefmt MY_DIR +``` -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. +## Format -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +`turtlefmt` is in development and its output format is not stable yet. -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +Example: +```turtle +@prefix ex: . # Prefix +@prefix xsd: . -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +# Some facts -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. + a ex:Foo ; +

"foo"@en , ( +01 +1.0 1.0e0 ) . # Foo -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +# An anonymous blank node +[ ex:p ex:o , ex:o2 ; ex:p2 ex:o3 ] ex:p3 true . # Bar +``` -## Contributing -State if you are open to contributions and what your requirements are for accepting them. +For now, it: +* Validates that the file is valid. +* Maintains consistent indentation and line jumps. +* Normalises string and IRI escapes to reduce their number as much as possible. +* Enforces the use of `"` instead of `'` in literals. +* Uses literals short notation for booleans, integers, decimals and doubles when it keeps the lexical representation unchanged. +* Uses `a` for `rdf:type` where possible. -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +## License -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +Copyright 2022 Helsing GmbH -## License -For open source projects, say how it is licensed. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..853e128 --- /dev/null +++ b/build.rs @@ -0,0 +1,34 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use std::path::Path; + +fn main() { + let base_path = Path::new("tree-sitter").to_path_buf(); + let grammar_path = base_path.join("grammar.js"); + let src_path = base_path.join("src"); + let source_path = src_path.join("parser.c"); + + tree_sitter_cli::generate::generate_parser_in_directory(&base_path, None, 14, false, None) + .unwrap(); + + cc::Build::new() + .include(&src_path) + .file(&source_path) + .compile("parser"); + + println!("cargo:rerun-if-changed={}", grammar_path.to_str().unwrap()); +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ce5176c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[project] +name = "turtlefmt" +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Rust", +] + +[project.urls] +Source = "https://gitlab.com/helsing/turtlefmt" +Tracker = "https://gitlab.com/helsing/turtlefmt/-/issues" + +[build-system] +requires = ["maturin>=0.14,<0.15"] +build-backend = "maturin" + +[tool.maturin] +bindings = "bin" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..f0d4330 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,714 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use anyhow::{anyhow, bail, Error, Result}; +use std::borrow::Cow; +use std::collections::HashMap; +use std::fmt::Write; +use tree_sitter::{Language, Node}; + +pub struct FormatOptions { + pub indentation: usize, +} + +impl Default for FormatOptions { + fn default() -> Self { + Self { indentation: 4 } + } +} + +fn get_tree_sitter_turtle() -> Language { + extern "C" { + fn tree_sitter_turtle() -> Language; + } + unsafe { tree_sitter_turtle() } +} + +pub fn format_turtle(original: &str, options: &FormatOptions) -> Result { + let mut parser = tree_sitter::Parser::new(); + parser.set_language(get_tree_sitter_turtle())?; + let tree = parser.parse(original.as_bytes(), None).unwrap(); + + let mut formatted = String::new(); + TurtleFormatter { + file: original.as_bytes(), + output: &mut formatted, + options, + prefixes: HashMap::new(), + } + .fmt_doc(tree.root_node())?; + Ok(formatted) +} + +struct TurtleFormatter<'a, W: Write> { + file: &'a [u8], + output: W, + options: &'a FormatOptions, + prefixes: HashMap, +} + +impl<'a, W: Write> TurtleFormatter<'a, W> { + fn fmt_doc(&mut self, node: Node<'_>) -> Result<()> { + debug_assert_eq!(node.kind(), "turtle_doc"); + #[derive(Eq, PartialEq)] + enum Context { + Start, + Prefixes, + Triples, + Comment, + } + + let mut context = Context::Start; + let mut row = node.start_position().row; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => { + if child.start_position().row == row { + // Inline comment + self.fmt_comments([child], true)?; + if context == Context::Start { + context = Context::Comment; + } + } else { + // Block comment + if context != Context::Start { + for _ in 0..(child.start_position().row - row) + .clamp(if context == Context::Comment { 1 } else { 2 }, 4) + { + writeln!(self.output)?; + } + } + self.fmt_comments([child], false)?; + context = Context::Comment; + } + } + "base" => { + if context != Context::Start { + writeln!(self.output)?; + } + if context == Context::Triples { + writeln!(self.output)?; + } + self.fmt_base(child)?; + context = Context::Prefixes; + } + "prefix" => { + if context != Context::Start { + writeln!(self.output)?; + } + if context == Context::Triples { + writeln!(self.output)?; + } + self.fmt_prefix(child)?; + context = Context::Prefixes; + } + "triples" => { + if context != Context::Start { + if context != Context::Comment || child.start_position().row > row + 1 { + writeln!(self.output)?; + } + writeln!(self.output)?; + } + self.fmt_triples(child)?; + context = Context::Triples; + } + _ => bail!("Unexpected turtle_doc child: {}", child.to_sexp()), + } + row = child.end_position().row; + } + writeln!(self.output)?; + Ok(()) + } + + fn fmt_base(&mut self, node: Node<'_>) -> Result<()> { + debug_assert_eq!(node.kind(), "base"); + let mut comments = Vec::new(); + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + "iriref" => { + let iri = self.extract_iriref(child)?; + write!(self.output, "@base <{iri}>")?; + } + _ => bail!("Unexpected base child: {}", child.to_sexp()), + } + } + write!(self.output, " .")?; + self.fmt_comments(comments, true) + } + + fn fmt_prefix(&mut self, node: Node<'_>) -> Result<()> { + debug_assert_eq!(node.kind(), "prefix"); + let mut comments = Vec::new(); + let mut prefix = ""; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + "pn_prefix" => { + prefix = child.utf8_text(self.file)?; + } + "iriref" => { + let iri = self.extract_iriref(child)?; + write!(self.output, "@prefix {prefix}: <{iri}>")?; + self.prefixes.insert(prefix.to_string(), iri); + } + _ => bail!("Unexpected prefix child: {}", child.to_sexp()), + } + } + write!(self.output, " .")?; + self.fmt_comments(comments, true) + } + + fn fmt_triples(&mut self, node: Node<'_>) -> Result<()> { + debug_assert_eq!(node.kind(), "triples"); + let mut comments = Vec::new(); + let mut is_first_predicate_objects = true; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + "predicate_objects" => { + if is_first_predicate_objects { + write!(self.output, " ")?; + is_first_predicate_objects = false; + } else { + write!(self.output, " ;")?; + self.fmt_comments(comments.drain(0..), true)?; + writeln!(self.output)?; + for _ in 0..self.options.indentation { + write!(self.output, " ")?; + } + } + self.fmt_predicate_objects(child, &mut comments)?; + } + _ => { + // The subject + self.fmt_term(child, &mut comments, false)?; + } + } + } + write!(self.output, " .")?; + self.fmt_comments(comments, true) + } + + fn fmt_predicate_objects<'b>( + &mut self, + node: Node<'b>, + comments: &mut Vec>, + ) -> Result<()> { + debug_assert_eq!(node.kind(), "predicate_objects"); + let mut is_predicate = true; + let mut is_first_object = true; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + _ => { + if is_predicate { + self.fmt_term(child, comments, true)?; + is_predicate = false; + } else { + if is_first_object { + write!(self.output, " ")?; + is_first_object = false; + } else { + write!(self.output, " , ")?; + } + self.fmt_term(child, comments, false)?; + } + } + } + } + Ok(()) + } + + fn fmt_term<'b>( + &mut self, + node: Node<'b>, + comments: &mut Vec>, + is_predicate: bool, + ) -> Result<()> { + enum LiteralAnnotation { + None, + LangTag(String), + IriRef(String), + PrefixedName(String, String), + } + + match node.kind() { + "iriref" => { + let iri = self.extract_iriref(node)?; + if is_predicate && iri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" { + write!(self.output, "a") + } else { + write!(self.output, "<{iri}>") + }?; + } + "prefixed_name" => { + let ((prefix, local), iri) = self.extract_prefixed_name(node)?; + if is_predicate && iri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" { + write!(self.output, "a") + } else { + write!(self.output, "{prefix}:{local}") + }?; + } + "a" => write!(self.output, "a")?, + "anon" => write!(self.output, "[]")?, + "blank_node_label" => write!(self.output, "_:{}", node.utf8_text(self.file)?)?, + "blank_node_property_list" => { + let mut is_first_predicate_objects = true; + write!(self.output, "[")?; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + _ => { + if is_first_predicate_objects { + write!(self.output, " ")?; + is_first_predicate_objects = false; + } else { + write!(self.output, " ; ")?; + } + self.fmt_predicate_objects(child, comments)?; + } + } + } + write!(self.output, " ]")?; + } + "collection" => { + write!(self.output, "(")?; + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + _ => { + write!(self.output, " ")?; + self.fmt_term(child, comments, false)?; + } + } + } + write!(self.output, " )")?; + } + "literal" => { + let mut value = String::new(); + let mut is_long_string = false; + let mut annotation = LiteralAnnotation::None; + let mut datatype = Cow::Borrowed("http://www.w3.org/2001/XMLSchema#string"); + for child in Self::iter_children(node)? { + match child.kind() { + "comment" => comments.push(child), + "string" => (value, is_long_string) = self.extract_string(child)?, + "langtag" => { + annotation = + LiteralAnnotation::LangTag(child.utf8_text(self.file)?.to_string()); + datatype = + "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString".into(); + } + "iriref" => { + let iriref = self.extract_iriref(child)?; + annotation = LiteralAnnotation::IriRef(iriref.clone()); + datatype = iriref.into(); + } + "prefixed_name" => { + let ((prefix, local), resolved_iri) = + self.extract_prefixed_name(child)?; + annotation = LiteralAnnotation::PrefixedName(prefix, local); + datatype = resolved_iri.into(); + } + "@" | "^^" | "<" | ">" => (), + _ => bail!("Unexpected literal child: {}", child.to_sexp()), + } + } + match datatype.as_ref() { + "http://www.w3.org/2001/XMLSchema#boolean" + if matches!(value.as_str(), "true" | "false") => + { + write!(self.output, "{value}") + } + "http://www.w3.org/2001/XMLSchema#integer" if is_turtle_integer(&value) => { + write!(self.output, "{value}") + } + "http://www.w3.org/2001/XMLSchema#decimal" if is_turtle_decimal(&value) => { + write!(self.output, "{value}") + } + "http://www.w3.org/2001/XMLSchema#double" if is_turtle_double(&value) => { + write!(self.output, "{value}") + } + _ => { + if is_long_string { + write!(self.output, "\"\"\"{value}\"\"\"")?; + } else { + write!(self.output, "\"{value}\"")?; + } + match annotation { + LiteralAnnotation::None => Ok(()), + LiteralAnnotation::LangTag(l) => write!(self.output, "@{l}"), + LiteralAnnotation::IriRef(i) => write!(self.output, "^^<{i}>"), + LiteralAnnotation::PrefixedName(prefix, local) => { + write!(self.output, "^^{prefix}:{local}") + } + } + } + }?; + } + "integer" => { + let value = node.utf8_text(self.file)?; + debug_assert!(is_turtle_integer(value), "{value} should be an integer"); + write!(self.output, "{value}")? + } + "boolean" => { + let value = node.utf8_text(self.file)?; + debug_assert!( + matches!(value, "true" | "false"), + "{value} should be true or false" + ); + write!(self.output, "{value}")? + } + "decimal" => { + let value = node.utf8_text(self.file)?; + debug_assert!(is_turtle_decimal(value), "{value} should be a decimal"); + write!(self.output, "{value}")? + } + "double" => { + let value = node.utf8_text(self.file)?; + debug_assert!(is_turtle_double(value), "{value} should be a double"); + write!(self.output, "{value}")? + } + _ => bail!("Unexpected term: {}", node.to_sexp()), + } + Ok(()) + } + + fn extract_iriref(&mut self, node: Node<'_>) -> Result { + debug_assert_eq!(node.kind(), "iriref"); + // We normalize the IRI + let raw = node.utf8_text(self.file)?; + let mut normalized = String::with_capacity(raw.len()); + for c in StringDecoder::new(raw) { + match c? { + c @ ('\x00'..='\x20' | '<' | '>' | '"' | '{' | '}' | '|' | '^' | '`' | '\\') => { + bail!("The character '{c:?} is not allowed in IRIs") + } + c => normalized.push(c), + } + } + Ok(normalized) + } + + fn extract_prefixed_name(&mut self, node: Node<'_>) -> Result<((String, String), String)> { + let (prefix, local) = node.utf8_text(self.file)?.split_once(':').unwrap(); + let Some(prefix_value) = self.prefixes.get(prefix) else { + bail!( + "The prefix {prefix}: is not defined on line {}", + node.start_position().row + 1 + ); + }; + + let mut normalized_local = String::with_capacity(local.len()); + let mut in_escape = false; + for c in local.chars() { + if in_escape { + match c { + '_' => normalized_local.push(c), + '.' | '-' => { + if normalized_local.is_empty() { + normalized_local.push('\\'); + normalized_local.push(c); + } else { + normalized_local.push(c); + } + } + '~' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | ';' | '=' + | '/' | '?' | '#' | '@' | '%' => { + normalized_local.push('\\'); + normalized_local.push(c); + } + c => bail!("Unexpected escape character \\{c}"), + } + in_escape = false; + } else if c == '\\' { + in_escape = true + } else { + normalized_local.push(c) + } + } + if normalized_local.ends_with('.') { + // We are not allowed to end with '.' + normalized_local.pop(); + normalized_local.push_str("\\."); + } + + let resolved = format!("{prefix_value}{normalized_local}"); + Ok(((prefix.to_string(), normalized_local), resolved)) + } + + fn extract_string(&mut self, node: Node<'_>) -> Result<(String, bool)> { + debug_assert_eq!(node.kind(), "string"); + + let raw = node.utf8_text(self.file)?; + if raw.starts_with("\"\"\"") || raw.starts_with("'''") { + // We normalize the multi-lines string + let mut raw = &raw[3..raw.len() - 3]; + let mut normalized = String::with_capacity(raw.len()); + // Hack: double quotes at the end should be escaped + let mut number_of_end_double_quotes = 0; + loop { + if raw.ends_with("\\\"") { + raw = &raw[..raw.len() - 2]; + number_of_end_double_quotes += 1; + } else if raw.ends_with('"') { + raw = &raw[..raw.len() - 1]; + number_of_end_double_quotes += 1; + } else { + break; + } + } + let mut previous_double_quotes = 0; + for c in StringDecoder::new(raw) { + match c? { + '"' => { + if previous_double_quotes >= 2 { + normalized.push_str("\\\""); + } else { + normalized.push('"'); + previous_double_quotes += 1; + } + } + '\\' => { + normalized.push_str("\\\\"); + previous_double_quotes = 0; + } + c => { + normalized.push(c); + previous_double_quotes = 0; + } + } + } + for _ in 0..number_of_end_double_quotes { + normalized.push_str("\\\""); + } + + Ok((normalized, true)) + } else { + // We normalize the one-line string + let raw = &raw[1..raw.len() - 1]; + let mut normalized = String::with_capacity(raw.len()); + for c in StringDecoder::new(raw) { + match c? { + '"' => { + normalized.push_str("\\\""); + } + '\\' => { + normalized.push_str("\\\\"); + } + '\r' => { + normalized.push_str("\\r"); + } + '\n' => { + normalized.push_str("\\n"); + } + '\t' => { + normalized.push_str("\\t"); + } + c => normalized.push(c), + } + } + + Ok((normalized, false)) + } + } + + fn fmt_comments<'b>( + &mut self, + nodes: impl IntoIterator>, + inline: bool, + ) -> Result<()> { + let comments = nodes + .into_iter() + .map(|node| Ok(node.utf8_text(self.file)?[1..].trim())) + .collect::>>()?; + if !comments.is_empty() { + if inline { + write!(self.output, " ")?; + } + write!(self.output, "# {}", comments.join(" "))?; + } + Ok(()) + } + + fn iter_children(node: Node<'_>) -> Result>> { + let mut walk = node.walk(); + node.children(&mut walk) + .filter_map(|child| { + if child.is_error() || child.is_missing() { + Some(Err(Self::fmt_err(child))) + } else if child.is_named() { + Some(Ok(child)) + } else { + None + } + }) + .collect() + } + + fn fmt_err(node: Node<'_>) -> Error { + let start = node.start_position(); + let end = node.end_position(); + if start.row == end.row { + anyhow!( + "Error on line {} between bytes {} and {}: {}", + start.row + 1, + start.column + 1, + end.column + 1, + node.to_sexp() + ) + } else { + anyhow!( + "Error between lines {} and {}: {}", + start.row + 1, + end.row + 1, + node.to_sexp() + ) + } + } +} + +struct StringDecoder<'a> { + input: &'a str, + i: usize, +} + +impl<'a> StringDecoder<'a> { + fn new(input: &'a str) -> Self { + Self { input, i: 0 } + } +} + +impl<'a> Iterator for StringDecoder<'a> { + type Item = Result; + + fn next(&mut self) -> Option> { + let c = self.input[self.i..].chars().next()?; + Some(if c == '\\' { + match self.input[self.i + 1..].chars().next().unwrap() { + 'u' => { + self.i += 6; + decode_uchar(&self.input[self.i - 6..self.i]) + } + 'U' => { + self.i += 10; + decode_uchar(&self.input[self.i - 10..self.i]) + } + c => { + self.i += c.len_utf8() + 1; + decode_echar(c) + } + } + } else { + self.i += c.len_utf8(); + Ok(c) + }) + } +} + +fn decode_echar(c: char) -> Result { + match c { + 't' => Ok('\t'), + 'b' => Ok('\x08'), + 'n' => Ok('\n'), + 'r' => Ok('\r'), + 'f' => Ok('\x0C'), + '"' => Ok('"'), + '\'' => Ok('\''), + '\\' => Ok('\\'), + _ => bail!("The escaped character '\\{c}' is not valid"), + } +} + +fn decode_uchar(input: &str) -> Result { + char::from_u32(u32::from_str_radix(&input[2..], 16).unwrap()).ok_or_else(|| { + anyhow!("The escaped unicode character '{input}' is not encoding a valid unicode character") + }) +} + +fn is_turtle_integer(value: &str) -> bool { + // [19] INTEGER ::= [+-]? [0-9]+ + let mut value = value.as_bytes(); + if value.starts_with(b"+") || value.starts_with(b"-") { + value = &value[1..]; + } + !value.is_empty() && value.iter().all(|c| c.is_ascii_digit()) +} + +fn is_turtle_decimal(value: &str) -> bool { + // [20] DECIMAL ::= [+-]? [0-9]* '.' [0-9]+ + let mut value = value.as_bytes(); + if value.starts_with(b"+") || value.starts_with(b"-") { + value = &value[1..]; + } + while value.first().map_or(false, |c| c.is_ascii_digit()) { + value = &value[1..]; + } + if !value.starts_with(b".") { + return false; + } + value = &value[1..]; + !value.is_empty() && value.iter().all(|c| c.is_ascii_digit()) +} + +fn is_turtle_double(value: &str) -> bool { + // [21] DOUBLE ::= [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.' [0-9]+ EXPONENT | [0-9]+ EXPONENT) + // [154s] EXPONENT ::= [eE] [+-]? [0-9]+ + let mut value = value.as_bytes(); + if value.starts_with(b"+") || value.starts_with(b"-") { + value = &value[1..]; + } + let mut with_before = false; + while value.first().map_or(false, |c| c.is_ascii_digit()) { + value = &value[1..]; + with_before = true; + } + let mut with_after = false; + if value.starts_with(b".") { + value = &value[1..]; + while value.first().map_or(false, |c| c.is_ascii_digit()) { + value = &value[1..]; + with_after = true; + } + } + if !(value.starts_with(b"e") || value.starts_with(b"E")) { + return false; + } + value = &value[1..]; + if value.starts_with(b"+") || value.starts_with(b"-") { + value = &value[1..]; + } + (with_before || with_after) && !value.is_empty() && value.iter().all(|c| c.is_ascii_digit()) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::path::Path; + + #[test] + fn tree_sitter() -> Result<()> { + tree_sitter_cli::test::run_tests_at_path( + get_tree_sitter_turtle(), + &Path::new("tree-sitter").join("corpus"), + false, + false, + None, + false, + ) + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..2a60c91 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,96 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use anyhow::{bail, Context, Result}; +use clap::Parser; +use diffy::{create_patch, PatchFormatter}; +use std::ffi::OsStr; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::ExitCode; +use turtlefmt::{format_turtle, FormatOptions}; + +/// Apply a consistent formatting to a Turtle file +#[derive(Parser, Debug)] +#[command(author, version, about)] +struct Args { + /// File(s) or directory to format. + #[arg()] + src: Vec, + /// Do not edit the file but only checks if it already applies the tool format. + #[arg(long)] + check: bool, + /// Number of spaces in the indentation + #[arg(long, default_value = "4")] + indentation: usize, +} + +fn main() -> Result { + let args = Args::parse(); + let options = FormatOptions { + indentation: args.indentation, + }; + let mut exit_code = ExitCode::SUCCESS; + + let mut files = Vec::new(); + for source in args.src { + if source.is_file() { + files.push(source); + } else if source.is_dir() { + add_files_with_suffix(&source, OsStr::new("ttl"), &mut files)?; + } else { + bail!( + "The target to format {} does not seem to exist", + source.display() + ); + } + } + + for file in files { + let original = fs::read_to_string(&file) + .with_context(|| format!("Error while reading {}", file.display()))?; + let formatted = format_turtle(&original, &options)?; + if original == formatted { + // Nothing to do + continue; + } + if args.check { + let patch = create_patch(&original, &formatted); + eprintln!("The format of {} is not correct", file.display()); + println!("{}", PatchFormatter::new().with_color().fmt_patch(&patch)); + } else { + fs::write(&file, formatted)?; + } + exit_code = ExitCode::from(65); + } + Ok(exit_code) +} + +fn add_files_with_suffix(dir: &Path, extension: &OsStr, files: &mut Vec) -> Result<()> { + for entry in fs::read_dir(dir)? { + let entry = entry?; + let entry_type = entry.file_type()?; + if entry_type.is_file() { + let file = entry.path(); + if file.extension() == Some(extension) { + files.push(file); + } + } else if entry_type.is_dir() { + add_files_with_suffix(&entry.path(), extension, files)?; + } + } + Ok(()) +} diff --git a/tests/format.rs b/tests/format.rs new file mode 100644 index 0000000..f9c72bf --- /dev/null +++ b/tests/format.rs @@ -0,0 +1,36 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use turtlefmt::{format_turtle, FormatOptions}; + +#[test] +fn test_format() { + let input = include_str!("from.simple.ttl"); + let expected = include_str!("to.simple.ttl"); + assert_eq!( + format_turtle(input, &FormatOptions::default()).unwrap(), + expected + ); +} + +#[test] +fn test_stable() { + let file = include_str!("to.simple.ttl"); + assert_eq!( + format_turtle(file, &FormatOptions::default()).unwrap(), + file + ); +} diff --git a/tests/from.simple.ttl b/tests/from.simple.ttl new file mode 100644 index 0000000..b9ee67a --- /dev/null +++ b/tests/from.simple.ttl @@ -0,0 +1,26 @@ +BASE # Base + +@prefix ex: # Prefix +. +PREFIX xsd: +PREFIX rdf: + +# Plain +# Plain 2 + +# Plain 3 + + a ex:Foo ; +

, ex:\-v\-\_v\.\. , "foo\u00E9\t\n\r'\"\u0022" , 'bar\U000000E9\'"' , "bar"@en-US , "test"^^ , ( +01 +1.0 1.0e0 ) . # Foo +# Comment +[ ex:p ex:o , ex:o2 ; ex:p2 ex:o3 ] rdf:type ex:o4 . # Bar + + +# Literal normalization +

""" foo + bar"\n\tbaz\"\"\" +\"""" . + +

'''foo'"bar''' . + +

"true"^^xsd:boolean , "false"^^ , "+12"^^xsd:integer , "1.1"^^xsd:decimal , "1.2e2"^^xsd:double . \ No newline at end of file diff --git a/tests/to.simple.ttl b/tests/to.simple.ttl new file mode 100644 index 0000000..136346c --- /dev/null +++ b/tests/to.simple.ttl @@ -0,0 +1,26 @@ +@base . # Base +@prefix ex: . # Prefix +@prefix xsd: . +@prefix rdf: . + +# Plain +# Plain 2 + +# Plain 3 + + a ex:Foo ; +

, ex:\-v-_v.\. , "fooé\t\n\r'\"\"" , "baré'\"" , "bar"@en-US , "test"^^ , ( +01 +1.0 1.0e0 ) . # Foo + +# Comment +[ ex:p ex:o , ex:o2 ; ex:p2 ex:o3 ] a ex:o4 . # Bar + + +# Literal normalization +

""" foo + bar" + baz""\" +\"""" . + +

"""foo'"bar""" . + +

true , false , +12 , 1.1 , 1.2e2 . diff --git a/tests/w3c_testsuite.rs b/tests/w3c_testsuite.rs new file mode 100644 index 0000000..57bd9ac --- /dev/null +++ b/tests/w3c_testsuite.rs @@ -0,0 +1,123 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use anyhow::{bail, Context, Result}; +use oxigraph::io::{GraphFormat, GraphParser}; +use oxigraph::model::vocab::rdf; +use oxigraph::model::{Graph, NamedNodeRef, SubjectRef, TermRef}; +use std::collections::hash_map::DefaultHasher; +use std::hash::Hasher; +use std::path::Path; +use std::{fs, str}; +use turtlefmt::{format_turtle, FormatOptions}; + +const CACHE: &str = "tests/cache"; + +fn get_remote_file(url: &str) -> Result { + let mut hasher = DefaultHasher::new(); + hasher.write(url.as_bytes()); + let cache_path = Path::new(CACHE).join(hasher.finish().to_string()); + if cache_path.exists() { + return Ok(fs::read_to_string(cache_path)?); + } + + let content = reqwest::blocking::get(url)?.error_for_status()?.text()?; + fs::write(cache_path, &content)?; + Ok(content) +} + +fn parse_turtle(url: &str, data: &str) -> Result { + GraphParser::from_format(GraphFormat::Turtle) + .with_base_iri(url)? + .read_triples(data.as_bytes())? + .collect::>() + .with_context(|| format!("Error while parsing:\n{data}")) +} + +fn run_test(test: SubjectRef<'_>, manifest: &Graph) -> Result<()> { + let Some(TermRef::NamedNode(test_type)) = manifest.object_for_subject_predicate( + test, + rdf::TYPE, + ) else { + bail!("No type") + }; + + let Some(TermRef::NamedNode(input_url)) = manifest.object_for_subject_predicate( + test, + NamedNodeRef::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action")?, + ) else { + bail!("No action") + }; + let original = get_remote_file(input_url.as_str())?.replace('\0', ""); + let formatted_result = format_turtle(&original, &FormatOptions::default()); + + match test_type.as_str() { + "http://www.w3.org/ns/rdftest#TestTurtleEval" + | "http://www.w3.org/ns/rdftest#TestTurtlePositiveSyntax" => { + let formatted = formatted_result?; + let mut original_graph = parse_turtle(input_url.as_str(), &original)?; + original_graph.canonicalize(); + let mut formatted_graph = parse_turtle(input_url.as_str(), &formatted)?; + formatted_graph.canonicalize(); + if original_graph != formatted_graph { + bail!("The formatted graph is not the same as the original graph.\nOriginal:\n{}\n\nFormatted:\n{}", original, formatted); + } + let reformatted = format_turtle(&formatted, &FormatOptions::default())?; + if formatted != reformatted { + bail!( + "The formatting is not stable.\nOriginal:\n{}\n\nReformatted:\n{}", + formatted, + reformatted + ); + } + Ok(()) + } + "http://www.w3.org/ns/rdftest#TestTurtleNegativeSyntax" => { + if formatted_result.is_ok() { + bail!( + "The following file has been parsed without error even if it should fail:\n{}", + original + ) + } + Ok(()) + } + _ => Ok(()), + } +} + +#[test] +fn test_w3c_files() -> Result<()> { + fs::create_dir_all(CACHE)?; // We ensure cache existence + + let manifest = parse_turtle( + "http://w3c.github.io/rdf-tests/turtle/manifest.ttl", + &get_remote_file("http://w3c.github.io/rdf-tests/turtle/manifest.ttl")?, + )?; + let errors = manifest + .subjects_for_predicate_object( + NamedNodeRef::new("http://www.w3.org/ns/rdftest#approval")?, + NamedNodeRef::new("http://www.w3.org/ns/rdftest#Approved")?, + ) + .filter_map(|t| { + run_test(t, &manifest) + .with_context(|| format!("{t} failed")) + .map_err(|e| format!("{e:?}")) + .err() + }) + .collect::>(); + assert!(errors.is_empty(), "{}", errors.join("\n")); + Ok(()) +} diff --git a/tree-sitter/corpus/mapping.txt b/tree-sitter/corpus/mapping.txt new file mode 100644 index 0000000..c557499 --- /dev/null +++ b/tree-sitter/corpus/mapping.txt @@ -0,0 +1,45 @@ +=================================== +Complete file to check node mapping +=================================== + +@base . +base +@prefix ex: . +prefix ex: +ex:foo a ex:Bar ; # test +

( "s" "s"@en "s"^^

) , 12 , true , _:foo , [] . +[ ex:p 1.2 , 1.2e3 ] . +[] ex:p 'a\'\u1111\UaAbBcCbD' , """b""c""" , '''c''c''' . +--- + +(turtle_doc + (base iri: (iriref)) + (base iri: (iriref)) + (prefix label: (pn_prefix) iri: (iriref)) + (prefix label: (pn_prefix) iri: (iriref)) + (triples + subject: (prefixed_name) + (predicate_objects + predicate: (a) + (prefixed_name)) + (comment) + (predicate_objects + predicate: (iriref) + (collection (literal value: (string)) (literal value: (string) language: (langtag)) (literal value: (string) datatype: (iriref))) + (integer) + (boolean) + (blank_node_label) + (anon))) + (triples + subject: (blank_node_property_list + (predicate_objects + predicate: (prefixed_name) + (decimal) + (double)))) + (triples + subject: (anon) + (predicate_objects + predicate: (prefixed_name) + (literal value: (string)) + (literal value: (string)) + (literal value: (string))))) diff --git a/tree-sitter/grammar.js b/tree-sitter/grammar.js new file mode 100644 index 0000000..5f0931d --- /dev/null +++ b/tree-sitter/grammar.js @@ -0,0 +1,163 @@ +/* + Copyright 2022 Helsing GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +function caseInsensitive(word) { + return alias(new RegExp(word.split('') + .map(letter => `[${letter.toLowerCase()}${letter.toUpperCase()}]`) + .join('')), word); +} + +// [163s] PN_CHARS_BASE ::= [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] +const PN_CHAR_BASE = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}' + +// [164s] PN_CHARS_U ::= PN_CHARS_BASE | '_' +const PN_CHARS_U = PN_CHAR_BASE + '_' + +// [166s] PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] +const PN_CHARS = PN_CHARS_U + '\\-0-9\u00B7\u0300-\u036F\u203F-\u2040' + +// [169s] PLX ::= PERCENT | PN_LOCAL_ESC +// [170s] PERCENT ::= '%' HEX HEX +// [171s] HEX ::= [0-9] | [A-F] | [a-f] +// [172s] PN_LOCAL_ESC ::= '\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%') +const PLX = '%[0-9a-fA-F]{2}|\\\\[_~.\\-!$&\'()*+,;=/?#@%]' + +module.exports = grammar({ + name: 'turtle', + + extras: $ => [/\s*/, $.comment], + + rules: { + // [1] turtleDoc ::= statement* + turtle_doc: $ => repeat($._statement), + + // [2] statement ::= directive | triples '.' + _statement: $ => choice($._directive, $.triples), // We move the '.' to the triples rule to make the AST cleaner + + // [3] directive ::= prefixID | base | sparqlPrefix | sparqlBase + _directive: $ => choice($.prefix, $.base), + + // [4] prefixID ::= '@prefix' PNAME_NS IRIREF '.' + // [6s] sparqlPrefix ::= "PREFIX" PNAME_NS IRIREF + prefix: $ => choice(seq('@prefix', field('label', $._pname_ns), field('iri', $._iriref), '.'), seq(caseInsensitive('PREFIX'), field('label', $._pname_ns), field('iri', $._iriref))), + + // [5] base ::= '@base' IRIREF '.' + // [5s] sparqlBase ::= "BASE" IRIREF + base: $ => choice(seq('@base', field('iri', $._iriref), '.'), seq(caseInsensitive('BASE'), field('iri', $._iriref))), + + // [6] triples ::= subject predicateObjectList | blankNodePropertyList predicateObjectList? + triples: $ => choice(seq(field('subject', $._subject), $._predicate_object_list, '.'), seq(field('subject', $.blank_node_property_list), optional($._predicate_object_list), '.')), + + // [7] predicateObjectList ::= verb objectList (';' (verb objectList)?)* + _predicate_object_list: $ => seq($.predicate_objects, repeat(seq(';', optional($.predicate_objects)))), + predicate_objects: $ => seq(field('predicate', $._verb), $._object_list), + + // [8] objectList ::= object (',' object)* + _object_list: $ => seq($._object, repeat(seq(',', $._object))), + + // [9] verb ::= predicate | 'a' + _verb: $ => choice($._predicate, $.a), + a: $ => 'a', + + // [10] subject ::= iri | BlankNode | collection + _subject: $ => choice($._iri, $._blank_node, $.collection), + + // [11] predicate ::= iri + _predicate: $ => $._iri, + + // [12] object ::= iri | BlankNode | collection | blankNodePropertyList | literal + _object: $ => choice($._iri, $._blank_node, $.collection, $.blank_node_property_list, $._literal), + + // [13] literal ::= RDFLiteral | NumericLiteral | BooleanLiteral + _literal: $ => choice($.literal, $._numeric_literal, $.boolean), + + // [14] blankNodePropertyList ::= '[' predicateObjectList ']' + blank_node_property_list: $ => seq('[', $._predicate_object_list, ']'), + + // [15] collection ::= '(' object* ')' + collection: $ => seq('(', repeat($._object), ')'), + + // [16] NumericLiteral ::= INTEGER | DECIMAL | DOUBLE + _numeric_literal: $ => choice($.integer, $.decimal, $.double), + + // [128s] RDFLiteral ::= String (LANGTAG | '^^' iri)? + literal: $ => seq(field('value', $.string), optional(choice(field('language', $._langtag), seq('^^', field('datatype', $._iri))))), + + // [133s] BooleanLiteral ::= 'true' | 'false' + boolean: $ => token(choice('true', 'false')), + + // [17] String ::= STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE | STRING_LITERAL_LONG_SINGLE_QUOTE | STRING_LITERAL_LONG_QUOTE + // [22] STRING_LITERAL_QUOTE ::= '"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR)* '"' /* #x22=" #x5C=\ #xA=new line #xD=carriage return */ + // [23] STRING_LITERAL_SINGLE_QUOTE ::= "'" ([^#x27#x5C#xA#xD] | ECHAR | UCHAR)* "'" /* #x27=' #x5C=\ #xA=new line #xD=carriage return */ + // [24] STRING_LITERAL_LONG_SINGLE_QUOTE ::= "'''" (("'" | "''")? ([^'\] | ECHAR | UCHAR))* "'''" + // [25] STRING_LITERAL_LONG_QUOTE ::= '"""' (('"' | '""')? ([^"\] | ECHAR | UCHAR))* '"""' + // [26] UCHAR ::= '\u' HEX HEX HEX HEX | '\U' HEX HEX HEX HEX HEX HEX HEX HEX + // [159s] ECHAR ::= '\' [tbnrf"'\] + // [171s] HEX ::= [0-9] | [A-F] | [a-f] + string: $ => choice( + /"([^"\\\r\n]|\\[tbnrf"'\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})*"/, + /'([^'\\\r\n]|\\[tbnrf"'\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})*'/, + /'''('?'?([^'\\]|\\[tbnrf"'\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}))*'''/, + /"""("?"?([^"\\]|\\[tbnrf"'\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}))*"""/, + ), + + // [135s] iri ::= IRIREF | PrefixedName + _iri: $ => choice($._iriref, $.prefixed_name), + + // [136s] PrefixedName ::= PNAME_LN | PNAME_NS + // [140s] PNAME_LN ::= PNAME_NS PN_LOCAL + prefixed_name: $ => new RegExp("([" + PN_CHAR_BASE + "]([" + PN_CHARS + ".]*[" + PN_CHARS + "])?)?:(([" + PN_CHARS_U + ":0-9]|" + PLX + ")(([" + PN_CHARS + ".:]|" + PLX + ")*([" + PN_CHARS + ":]|" + PLX + "))?)?", 'u'), + + // [137s] BlankNode ::= BLANK_NODE_LABEL | ANON + _blank_node: $ => choice($._blank_node_label, $.anon), + + // [18] IRIREF ::= '<' ([^#x00-#x20<>"{}|^`\] | UCHAR)* '>' /* #x00=NULL #01-#x1F=control codes #x20=space */ + _iriref: $ => seq('<', $.iriref, token.immediate('>')), + iriref: $ => token.immediate(/([^\x00-\x20<>"{}|^`\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})*/), + + // [139s] PNAME_NS ::= PN_PREFIX? ':' + _pname_ns: $ => seq(optional($.pn_prefix), ':'), + + // [141s] BLANK_NODE_LABEL ::= '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? + _blank_node_label: $ => seq('_:', $.blank_node_label), + blank_node_label: $ => token.immediate(new RegExp("[" + PN_CHARS_U + "0-9]([" + PN_CHARS + ".]*[" + PN_CHARS + "])?", 'u')), + + // [144s] LANGTAG ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* + _langtag: $ => seq('@', $.langtag), + langtag: $ => token.immediate(/[a-zA-Z]+(-[a-zA-Z0-9]+)*/), + + // [19] INTEGER ::= [+-]? [0-9]+ + integer: $ => /[+-]?[0-9]+/, + + // [20] DECIMAL ::= [+-]? [0-9]* '.' [0-9]+, + decimal: $ => /[+-]?[0-9]*\.[0-9]+/, + + // [21] DOUBLE ::= [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.' [0-9]+ EXPONENT | [0-9]+ EXPONENT) + // [154s] EXPONENT ::= [eE] [+-]? [0-9]+ + double: $ => /[+-]?([0-9]+\.[0-9]*[eE][+-]?[0-9]+|\.[0-9]+[eE][+-]?[0-9]+|[0-9]+[eE][+-]?[0-9]+)/, + + // [162s] ANON ::= '[' WS* ']' + anon: $ => /\[\s*]/, + + // [167s] PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? + pn_prefix: $ => new RegExp("[" + PN_CHAR_BASE + "]([" + PN_CHARS + ".]*[" + PN_CHARS + "])?", 'u'), + + // [168s] PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? + pn_local: $ => token.immediate(new RegExp("([" + PN_CHARS_U + ":0-9]|" + PLX + ")(([" + PN_CHARS + ".:]|" + PLX + ")*([" + PN_CHARS + ":]|" + PLX + "))?", 'u')), + + comment: $ => token(prec(-1, /#[^\r\n]*/)), + } +});