pax_global_header00006660000000000000000000000064147345140770014526gustar00rootroot0000000000000052 comment=c1f4ca71a4315472557b7bff5ae8c5fa6a0fc056 turtlefmt-0.1.2/000077500000000000000000000000001473451407700135545ustar00rootroot00000000000000turtlefmt-0.1.2/.github/000077500000000000000000000000001473451407700151145ustar00rootroot00000000000000turtlefmt-0.1.2/.github/workflows/000077500000000000000000000000001473451407700171515ustar00rootroot00000000000000turtlefmt-0.1.2/.github/workflows/build.yml000066400000000000000000000133401473451407700207740ustar00rootroot00000000000000name: build on: pull_request: branches: - main push: branches: - main release: types: - published concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: cargo fmt -- --check clippy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - run: cargo clippy --all-targets -- -D warnings -D clippy::all test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - uses: actions/cache@v4 with: path: tests/cache key: tests-cache - run: cargo test test_msv: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: rustup override set 1.81.0 - uses: Swatinem/rust-cache@v2 - uses: actions/cache@v4 with: path: tests/cache key: tests-cache - run: cargo test test_tree_sitter: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@v2 with: { tool: tree-sitter-cli } - run: tree-sitter generate working-directory: tree-sitter - run: tree-sitter test working-directory: tree-sitter - run: tree-sitter fuzz working-directory: tree-sitter rustdoc: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - run: cargo doc --no-deps env: RUSTDOCFLAGS: -D warnings typos: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: taiki-e/install-action@v2 with: { tool: typos-cli } - run: typos python_sdist: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: pip install maturin - run: maturin sdist - uses: actions/upload-artifact@v4 with: name: wheels path: target/wheels/*.tar.gz wheel_linux: runs-on: ubuntu-latest strategy: matrix: architecture: [ "x86_64", "aarch64" ] continue-on-error: true steps: - uses: actions/checkout@v4 - uses: docker/setup-qemu-action@v3 with: platforms: linux/${{ matrix.architecture }} if: matrix.architecture != 'x86_64' - uses: Swatinem/rust-cache@v2 - run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux_2_28_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build.sh - uses: actions/upload-artifact@v4 with: name: wheels_${{ matrix.architecture }}_linux path: target/wheels/*.whl wheel_linux_musl: runs-on: ubuntu-latest strategy: matrix: architecture: [ "x86_64" ] # TODO: aarch64 seems to fail for some reason continue-on-error: true steps: - uses: actions/checkout@v4 - uses: docker/setup-qemu-action@v3 with: platforms: linux/${{ matrix.architecture }} if: matrix.architecture != 'x86_64' - uses: Swatinem/rust-cache@v2 - run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/musllinux_1_2_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/musllinux_build.sh - uses: actions/upload-artifact@v4 with: name: wheels_${{ matrix.architecture }}_linux_musl path: target/wheels/*.whl wheel_mac: runs-on: macos-latest strategy: matrix: architecture: [ "x86_64", "aarch64" ] steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - run: rustup target add ${{ matrix.architecture }}-apple-darwin - uses: actions/setup-python@v5 with: python-version: "3.12" - run: pip install maturin - run: maturin build --release --target ${{ matrix.architecture }}-apple-darwin - uses: actions/upload-artifact@v4 with: name: wheels_${{ matrix.architecture }}_macos path: target/wheels/*.whl wheel_windows: runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse - run: pip install maturin - run: maturin build --release - uses: actions/upload-artifact@v4 with: name: wheels_x86_64_windows path: target/wheels/*.whl publish_pypi: if: github.event_name == 'release' runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/p/turtlefmt permissions: id-token: write needs: - python_sdist - wheel_windows - wheel_mac - wheel_linux - wheel_linux_musl steps: - uses: actions/download-artifact@v4 with: pattern: wheels_* path: dist merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist skip-existing: true python_test: runs-on: ubuntu-latest needs: - wheel_linux steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - uses: actions/download-artifact@v4 with: pattern: wheels_* path: dist merge-multiple: true - run: pip install --no-index --find-links=dist/ turtlefmt - run: turtlefmt --check tests/to.simple.ttl turtlefmt-0.1.2/.github/workflows/manylinux_build.sh000066400000000000000000000006321473451407700227110ustar00rootroot00000000000000cd /workdir dnf install -y dnf-plugins-core dnf module install -y nodejs:20 llvm-toolset:rhel8 curl https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init --output rustup-init chmod +x rustup-init ./rustup-init -y --profile minimal source "$HOME/.cargo/env" python3.12 -m venv venv source venv/bin/activate pip install maturin maturin build --release --compatibility manylinux_2_28 turtlefmt-0.1.2/.github/workflows/musllinux_build.sh000066400000000000000000000005401473451407700227230ustar00rootroot00000000000000cd /workdir apk add clang-dev nodejs curl https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-musl/rustup-init --output rustup-init chmod +x rustup-init ./rustup-init -y --profile minimal source "$HOME/.cargo/env" python3.12 -m venv venv source venv/bin/activate pip install maturin maturin build --release --compatibility musllinux_1_2 turtlefmt-0.1.2/.gitignore000066400000000000000000000000461473451407700155440ustar00rootroot00000000000000/target /tests/cache /tree-sitter/src turtlefmt-0.1.2/Cargo.lock000066400000000000000000001116571473451407700154740ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] name = "adler2" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anstream" version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", "windows-sys 0.59.0", ] [[package]] name = "anyhow" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", "windows-targets", ] [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" dependencies = [ "shlex", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", ] [[package]] name = "clap_builder" version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", ] [[package]] name = "clap_derive" version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", "quote", "syn", ] [[package]] name = "clap_lex" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "diffy" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d3041965b7a63e70447ec818a46b1e5297f7fcae3058356d226c02750c4e6cb" dependencies = [ "nu-ansi-term", ] [[package]] name = "displaydoc" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures-channel" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", ] [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-sink" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "http" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "http-body" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", ] [[package]] name = "http-body-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", "http", "http-body", "pin-project-lite", ] [[package]] name = "httparse" version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "hyper" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "httparse", "itoa", "pin-project-lite", "smallvec", "tokio", "want", ] [[package]] name = "hyper-util" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "hyper", "pin-project-lite", "socket2", "tokio", "tower-service", "tracing", ] [[package]] name = "icu_collections" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" dependencies = [ "displaydoc", "yoke", "zerofrom", "zerovec", ] [[package]] name = "icu_locid" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" dependencies = [ "displaydoc", "litemap", "tinystr", "writeable", "zerovec", ] [[package]] name = "icu_locid_transform" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" dependencies = [ "displaydoc", "icu_locid", "icu_locid_transform_data", "icu_provider", "tinystr", "zerovec", ] [[package]] name = "icu_locid_transform_data" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" [[package]] name = "icu_normalizer" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" dependencies = [ "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", "icu_provider", "smallvec", "utf16_iter", "utf8_iter", "write16", "zerovec", ] [[package]] name = "icu_normalizer_data" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" [[package]] name = "icu_properties" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" dependencies = [ "displaydoc", "icu_collections", "icu_locid_transform", "icu_properties_data", "icu_provider", "tinystr", "zerovec", ] [[package]] name = "icu_properties_data" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" [[package]] name = "icu_provider" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" dependencies = [ "displaydoc", "icu_locid", "icu_provider_macros", "stable_deref_trait", "tinystr", "writeable", "yoke", "zerofrom", "zerovec", ] [[package]] name = "icu_provider_macros" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "idna" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ "idna_adapter", "smallvec", "utf8_iter", ] [[package]] name = "idna_adapter" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ "icu_normalizer", "icu_properties", ] [[package]] name = "indexmap" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "indoc" version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "ipnet" version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is_terminal_polyfill" version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ "once_cell", "wasm-bindgen", ] [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "litemap" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] [[package]] name = "mio" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "wasi", "windows-sys 0.52.0", ] [[package]] name = "nu-ansi-term" version = "0.50.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "object" version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oxilangtag" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23f3f87617a86af77fa3691e6350483e7154c2ead9f1261b75130e21ca0f8acb" dependencies = [ "serde", ] [[package]] name = "oxiri" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6628603228a6483668f78b29dc400a33ff1444dd5eae0504e40b6ba3bf7d01de" [[package]] name = "oxrdf" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "934b857076ddaada5c987ef66c8a4e93ed10b7cd408ad15aa06a88762477a25d" dependencies = [ "oxilangtag", "oxiri", "rand", "thiserror", ] [[package]] name = "oxttl" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31b818f1b4303ed67685ff113d0814d00ef4b06c80a5d59828b16495b27461ad" dependencies = [ "memchr", "oxilangtag", "oxiri", "oxrdf", "thiserror", ] [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro2" version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" 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 = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fe060fe50f524be480214aba758c71f99f90ee8c83c5a36b5e9e1d568eb4eb3" dependencies = [ "base64", "bytes", "futures-channel", "futures-core", "futures-util", "http", "http-body", "http-body-util", "hyper", "hyper-util", "ipnet", "js-sys", "log", "mime", "once_cell", "percent-encoding", "pin-project-lite", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", "tower", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", "windows-registry", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "semver" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" dependencies = [ "serde", ] [[package]] name = "serde" version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "indexmap", "itoa", "memchr", "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 = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallbitvec" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3fc564a4b53fd1e8589628efafe57602d91bde78be18186b5f61e8faea470" [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "streaming-iterator" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" version = "2.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] [[package]] name = "synstructure" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "thiserror" version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tinystr" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ "displaydoc", "zerovec", ] [[package]] name = "tokio" version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "libc", "mio", "pin-project-lite", "socket2", "windows-sys 0.52.0", ] [[package]] name = "tower" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", "sync_wrapper", "tokio", "tower-layer", "tower-service", ] [[package]] name = "tower-layer" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] [[package]] name = "tree-sitter" version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f2434c86ba59ed15af56039cc5bf1acf8ba76ce301e32ef08827388ef285ec5" dependencies = [ "cc", "regex", "regex-syntax", "streaming-iterator", "tree-sitter-language", ] [[package]] name = "tree-sitter-generate" version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b30247f0782cbcec6e451ed460bf04921c8849f9ffa7b011ffae3f9d73fb14f" dependencies = [ "anyhow", "heck", "indexmap", "indoc", "lazy_static", "log", "regex", "regex-syntax", "rustc-hash", "semver", "serde", "serde_json", "smallbitvec", "tree-sitter", "url", ] [[package]] name = "tree-sitter-language" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c199356c799a8945965bb5f2c55b2ad9d9aa7c4b4f6e587fe9dea0bc715e5f9c" [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "turtlefmt" version = "0.1.2" dependencies = [ "anyhow", "cc", "clap", "diffy", "oxrdf", "oxttl", "reqwest", "tree-sitter", "tree-sitter-generate", ] [[package]] name = "unicode-ident" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "url" version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", "percent-encoding", "serde", ] [[package]] name = "utf16_iter" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" [[package]] name = "utf8_iter" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "want" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ "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.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" dependencies = [ "cfg-if", "js-sys", "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "windows-registry" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result", "windows-strings", "windows-targets", ] [[package]] name = "windows-result" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ "windows-targets", ] [[package]] name = "windows-strings" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ "windows-result", "windows-targets", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "write16" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" [[package]] name = "writeable" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "yoke" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", "yoke-derive", "zerofrom", ] [[package]] name = "yoke-derive" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zerofrom" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zerovec" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" dependencies = [ "yoke", "zerofrom", "zerovec-derive", ] [[package]] name = "zerovec-derive" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", "syn", ] turtlefmt-0.1.2/Cargo.toml000066400000000000000000000012131473451407700155010ustar00rootroot00000000000000[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://github.com/helsing-ai/turtlefmt" rust-version = "1.81.0" version = "0.1.2" [dependencies] anyhow = "1.0.86" clap = { version = "4.5.16", features = ["derive"] } diffy = "0.4.0" tree-sitter = "0.24.6" [dev-dependencies] oxrdf = "0.2.0" oxttl = "0.1.0" reqwest = { version = "0.12.7", default-features = false, features = ["blocking"] } [build-dependencies] cc = "1.1.15" tree-sitter-generate = "0.24.6" turtlefmt-0.1.2/HOW_TO_RELEASE.md000066400000000000000000000002711473451407700162750ustar00rootroot00000000000000To release a new version: 1. Update the version tag in `Cargo.toml` 2. Create the release tag on GitHub. Pypi release is automated in the CI. 3. Release on Crates.io: `cargo publish`. turtlefmt-0.1.2/LICENSE000066400000000000000000000261361473451407700145710ustar00rootroot00000000000000 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. turtlefmt-0.1.2/README.md000066400000000000000000000041341473451407700150350ustar00rootroot00000000000000# TurtleFmt `turtlefmt` is an auto formatter for [RDF Turtle](https://www.w3.org/TR/turtle/) under Apache 2 license. ## Installation It is currently distributed on: - [Crates.io](https://crates.io/crates/turtlefmt): `cargo install turtlefmt` - [Pypi](https://pypi.org/project/turtlefmt): `pipx install turtlefmt` Build from source requires NodeJS 6.0+ to be available in your `PATH`. ## Usage To use it: ```sh turtlefmt MY_TURTLE_FILE.ttl ``` It is also possible to check if formatting of a given file is valid according to the formatter using: ```sh turtlefmt --check MY_TURTLE_FILE.ttl ``` If the formatting is not valid, a patch to properly format the file is written to the standard output. It is also possible to check a complete directory (and its subdirectories): ```sh turtlefmt MY_DIR ``` ## Format `turtlefmt` is in development and its output format is not stable yet. Example: ```turtle @prefix ex: . # Prefix @prefix xsd: . # Some facts a ex:Foo ;

"foo"@en , ( +01 +1.0 1.0e0 ) . # Foo # An anonymous blank node [ ex:p ex:o , ex:o2 ; ex:p2 ex:o3 ] ex:p3 true . # Bar ``` 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. ## License 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. turtlefmt-0.1.2/build.rs000066400000000000000000000030501473451407700152170ustar00rootroot00000000000000/* 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; use std::{env, fs}; fn main() { // We copy TreeSitter data to a subdirectory of the build directory let source_path = Path::new("tree-sitter"); let build_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("tree-sitter"); if !build_path.exists() { fs::create_dir(&build_path).unwrap(); } fs::copy( source_path.join("grammar.js"), build_path.join("grammar.js"), ) .unwrap(); // We convert the TreeSitter grammar to C tree_sitter_generate::generate_parser_in_directory(&build_path, None, 14, None, None).unwrap(); // We build the C code let src_path = build_path.join("src"); cc::Build::new() .include(&src_path) .file(src_path.join("parser.c")) .compile("parser"); // We make sure the build is run again if the grammar changes println!( "cargo:rerun-if-changed={}", source_path.join("grammar.js").to_str().unwrap() ); } turtlefmt-0.1.2/pyproject.toml000066400000000000000000000007261473451407700164750ustar00rootroot00000000000000[project] name = "turtlefmt" classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Rust", ] dynamic = ["version"] [project.urls] Source = "https://github.com/helsing-ai/turtlefmt" Tracker = "https://github.com/helsing-ai/turtlefmt/issues" [build-system] requires = ["maturin~=1.0"] build-backend = "maturin" [tool.maturin] bindings = "bin" turtlefmt-0.1.2/src/000077500000000000000000000000001473451407700143435ustar00rootroot00000000000000turtlefmt-0.1.2/src/lib.rs000066400000000000000000000646761473451407700155020ustar00rootroot00000000000000/* 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 { /// Number of spaces used for one level of indentation 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 TurtleFormatter<'_, W> { fn fmt_doc(&mut self, node: Node<'_>) -> Result<()> { debug_assert_eq!(node.kind(), "turtle_doc"); let mut context = RootContext::Start; let mut row = node.start_position().row; let mut prefix_buffer: Vec<(Node<'_>, Vec>)> = Vec::new(); for child in Self::iter_children(node)? { match child.kind() { "comment" => { if child.start_position().row == row { if let Some((_, prefix_comments)) = prefix_buffer.last_mut() { // We keep the comment connected to the prefixes prefix_comments.push(child); } else { // Inline comment self.fmt_comments([child], true)?; if context == RootContext::Start { context = RootContext::Comment; } } } else { // Block comment self.fmt_possible_prefixes(&mut prefix_buffer, &mut context)?; if context != RootContext::Start { for _ in 0..(child.start_position().row - row).clamp( if context == RootContext::Comment { 1 } else { 2 }, 4, ) { writeln!(self.output)?; } } self.fmt_comments([child], false)?; context = RootContext::Comment; } } "base" => { self.fmt_possible_prefixes(&mut prefix_buffer, &mut context)?; if context != RootContext::Start { writeln!(self.output)?; } if context == RootContext::Triples { writeln!(self.output)?; } context = RootContext::Prefixes; self.fmt_base(child)?; } "prefix" => { prefix_buffer.push((child, Vec::new())); } "triples" => { self.fmt_possible_prefixes(&mut prefix_buffer, &mut context)?; if context != RootContext::Start { if context != RootContext::Comment || child.start_position().row > row + 1 { writeln!(self.output)?; } writeln!(self.output)?; } self.fmt_triples(child)?; context = RootContext::Triples; } _ => bail!("Unexpected turtle_doc child: {}", child.to_sexp()), } row = child.end_position().row; } self.fmt_possible_prefixes(&mut prefix_buffer, &mut context)?; writeln!(self.output)?; Ok(()) } fn fmt_possible_prefixes( &mut self, nodes: &mut Vec<(Node<'_>, Vec>)>, context: &mut RootContext, ) -> Result<()> { if nodes.is_empty() { return Ok(()); } if *context != RootContext::Start { writeln!(self.output)?; } if *context == RootContext::Triples { writeln!(self.output)?; } nodes.sort_by_key(|(node, _)| { node.child_by_field_name("label") .map_or("", |n| n.utf8_text(self.file).unwrap_or("")) }); for (i, (node, comments)) in nodes.iter().enumerate() { if i > 0 { writeln!(self.output)?; } debug_assert_eq!(node.kind(), "prefix"); self.fmt_prefix(*node)?; self.fmt_comments(comments.iter().copied(), true)?; } nodes.clear(); *context = RootContext::Prefixes; 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 new_indented_line(&mut self, indents: usize) -> Result<()> { writeln!(self.output)?; for _ in 0..(self.options.indentation * indents) { write!(self.output, " ")?; } Ok(()) } 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)?; self.new_indented_line(1)?; } 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 Iterator for StringDecoder<'_> { 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().is_some_and(|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().is_some_and(|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().is_some_and(|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()) } #[derive(Eq, PartialEq)] enum RootContext { Start, Prefixes, Triples, Comment, } turtlefmt-0.1.2/src/main.rs000066400000000000000000000060031473451407700156340ustar00rootroot00000000000000/* 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 check if it already applies this tools format. #[arg(long)] check: bool, /// Number of spaces per level of 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)); exit_code = ExitCode::from(65); } else { fs::write(&file, formatted)?; } } 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(()) } turtlefmt-0.1.2/tests/000077500000000000000000000000001473451407700147165ustar00rootroot00000000000000turtlefmt-0.1.2/tests/format.rs000066400000000000000000000020431473451407700165530ustar00rootroot00000000000000/* 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 ); } turtlefmt-0.1.2/tests/from.simple.ttl000066400000000000000000000013711473451407700177000ustar00rootroot00000000000000@base . # test @prefix ex: . # Prefix PREFIX xsd: PREFIX rdf: BASE # Base # 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 .turtlefmt-0.1.2/tests/to.simple.ttl000066400000000000000000000011631473451407700173560ustar00rootroot00000000000000@base . # test @prefix ex: . # Prefix @prefix rdf: . @prefix xsd: . @base . # Base # 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 . turtlefmt-0.1.2/tests/w3c_testsuite.rs000066400000000000000000000107151473451407700200750ustar00rootroot00000000000000/* 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 oxrdf::graph::CanonicalizationAlgorithm; use oxrdf::vocab::rdf; use oxrdf::{Graph, NamedNodeRef, SubjectRef, TermRef}; use oxttl::TurtleParser; 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 { TurtleParser::new() .with_base_iri(url)? .for_slice(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(CanonicalizationAlgorithm::Unstable); let mut formatted_graph = parse_turtle(input_url.as_str(), &formatted)?; formatted_graph.canonicalize(CanonicalizationAlgorithm::Unstable); 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/rdf/rdf11/rdf-turtle/manifest.ttl", &get_remote_file("http://w3c.github.io/rdf-tests/rdf/rdf11/rdf-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(()) } turtlefmt-0.1.2/tree-sitter/000077500000000000000000000000001473451407700160235ustar00rootroot00000000000000turtlefmt-0.1.2/tree-sitter/grammar.js000066400000000000000000000207161473451407700200150ustar00rootroot00000000000000/* 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]*/)), } }); turtlefmt-0.1.2/tree-sitter/test/000077500000000000000000000000001473451407700170025ustar00rootroot00000000000000turtlefmt-0.1.2/tree-sitter/test/corpus/000077500000000000000000000000001473451407700203155ustar00rootroot00000000000000turtlefmt-0.1.2/tree-sitter/test/corpus/mapping.txt000066400000000000000000000023701473451407700225130ustar00rootroot00000000000000=================================== 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))))) turtlefmt-0.1.2/tree-sitter/tree-sitter.json000066400000000000000000000003451473451407700211670ustar00rootroot00000000000000{ "grammars": [ { "name": "turtle", "camelcase": "Turtle", "scope": "source.turtle" } ], "metadata": { "version": "0.1.0", "license": "Apache-2.0", "authors": [] }, "bindings": {} }turtlefmt-0.1.2/typos.toml000066400000000000000000000001571473451407700156320ustar00rootroot00000000000000[files] extend-exclude = ["**/*.svg"] [default.extend-words] pn = "pn" # Common abbreviation in Turtle grammar