Skip to main content

tree-sitter-swi-prolog

Kibi requirement health

SWI-Prolog grammar for tree-sitter.

It parses the Prolog that real SWI-Prolog projects are written in, not only ISO core:

  • the default SWI-Prolog operator table, including : module qualification, => single-sided unification, =@=, >:<, :<, as, $, and declaration prefixes such as dynamic, discontiguous, meta_predicate, multifile and table
  • operators from common libraries: library(clpfd) (#=, in, .., ...), library(chr) (<=>, ==>, \), library(semweb/rdf_db) (^^), library(wasm) (#Value, Expr[Index]) and the rdf_meta, persistent, record and html_meta declarations
  • dicts (_{name: "x"}, Tag{...}) and functional notation on dicts (D.key, D.put(k, V))
  • strings, back-quoted strings, 0'c character codes, radix integers (16'FF), digit groups (1 000 000), rationals (1r3) and special floats (1.0Inf)
  • Unicode atoms and variables, multi-line quoted text, % and /* */ comments, and a leading #! line

Clauses are structured for tools: every top-level term is a clause (with head, neck and body fields), a directive or a query.

max(X, Y, X) :- X >= Y, !.

(clause
  head: (compound_term functor: (atom) arguments: (arguments (variable) (variable) (variable)))
  neck: (operator)
  body: (binary_operation left: (binary_operation ...) operator: (operator) right: (atom))
  (end))

Coverage

CI parses SWI-Prolog's own boot/ and library/ sources and fails if fewer than 99.5% of top-level terms parse without errors. On SWI-Prolog's current boot/ and library/ 99.88% of terms parse cleanly, and on the full SWI-Prolog 10.0.2 library with packages (413 files, about 240,000 lines) 99.91%; the rest use prefix operators their files declare themselves.

Limits

A tree-sitter grammar has a fixed operator table, so operators declared at load time with op/3 are not known while parsing:

  • an unknown infix operator between two operands, symbolic or alphanumeric (for example X ===> Y or X cis Y), is read as an infix operator at priority 700, so the clause still parses, with the grouping that priority gives
  • unknown prefix and postfix operators produce an ERROR node for that term only; the parser recovers at the next clause
  • the parser does not lower operator priorities the way SWI-Prolog does in some argument positions, so foo(:- a) or foo(a|b) are errors

A negative number literal is parsed as the prefix operator - applied to the number.

Queries

  • queries/highlights.scm: syntax highlighting
  • queries/tags.scm: predicate definitions (clause heads, including module-qualified heads and single-sided-unification heads with guards), module declarations, and calls. @name is the predicate name without arity; count the head's arguments for the arity, and add two for DCG rules (neck -->)
  • queries/locals.scm: variables are local to their clause, directive or query

Usage

Node, Rust, Python, Go, Swift and C bindings are generated by tree-sitter init. For the browser or other WebAssembly hosts, build the parser with:

npx tree-sitter build --wasm

and load tree-sitter-swi_prolog.wasm with web-tree-sitter.

Development

npm install
npx tree-sitter generate
npx tree-sitter test
npx tree-sitter build --wasm
node scripts/check-corpus.mjs path/to/prolog/sources

grammar.js lists the operator tables at the top. To support another library's operators, add them to the matching table with their SWI-Prolog priority and type.

Releasing

Releases are made from changesets.

  1. A pull request with a user-visible change adds a changeset: run npx changeset, pick the bump and describe the change for users.
  2. When it is merged, the Release workflow opens (or updates) a Version packages pull request that applies all pending changesets: it bumps the version in every manifest and writes their text into CHANGELOG.md.
  3. Merging that pull request releases the new version: the vX.Y.Z tag and GitHub release (with the changelog section as notes and the Wasm parser attached), npm, crates.io and PyPI.

The release step publishes only what is missing for the current version, so if a registry fails, run the Release workflow again from the Actions tab. Don't create tags or releases by hand.

License

MIT

Metadata

Release files for tree-sitter-swi-prolog 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-swi-prolog 0.1.1
File Size Uploaded Provenance Actions
tree_sitter_swi_prolog-0.1.1.tar.gz 106.0 kB Without provenance Details for tree_sitter_swi_prolog-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-swi-prolog 0.1.1
File Actions
tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_arm64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_amd64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details for tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl

Total release size: 616.6 kB

Release files / tree_sitter_swi_prolog-0.1.1.tar.gz

Download URL tree_sitter_swi_prolog-0.1.1.tar.gz
Size 106.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9adc1d025cd07664d5a65248ee13d65e55b2a5a02d4b79908379243c5ed36204
BLAKE2b-256 checksum
How to use checksums
293b5fdac06419ce7cb6561640cda1433e25039dfaceb579d67f171ba0fd003e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_arm64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_arm64.whl
Size 40.3 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
7a942bb7fad9e2da97e05dad45b9dc1a968fe228405df4b8175c84b63ce616a8
BLAKE2b-256 checksum
How to use checksums
bfabd79dbd488ba75b202e26345b4688f59a575c977a8c3108e5861fd33ea392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_amd64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-win_amd64.whl
Size 39.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0a84b73a17620b69ce09f4ebeea3371b630f2ba4354d0d392968ecb232dfa6cd
BLAKE2b-256 checksum
How to use checksums
98250b568075d07eaa82b5a36440643a2402f7bc231293a59632421517a7870a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 81.8 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
abb2b2c9551f2ad30d2c4d9be5cde894ffcb8db0371c7add0678e9a2c2b9561d
BLAKE2b-256 checksum
How to use checksums
49ddc1579d8c59cf117a3e0ae6a58527bed2ef67e001ca5d575240d97ed13c6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 88.6 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
109bc351125fcf732584296cee43506fbbee5f6fdc9e3e880e6923e4825b620f
BLAKE2b-256 checksum
How to use checksums
b648fe4d4372445e8bf1674bdfbcd77c540f5773f442ba1330bc9ce84373c4ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 90.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a26719b4c79d584a50479d6c8b5ab6c3c4b23a0a4c16e9f4a46cf809c33f959a
BLAKE2b-256 checksum
How to use checksums
9286b4e7d2b7f7816ee6e0404640d9162d69e91518c01f05ac6a08a8a683eab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 86.6 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
50a0fe00b50e082f6f68db891e961c71cef6091225e215cc85dd1a922b167837
BLAKE2b-256 checksum
How to use checksums
371bde1ffc14a259bcf4094030204f5e464474563ade3223a2c0dc8d2779970d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 42.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ed19f5acd6577b39da4591bafc9baaf2b5b3d69ccd2e8ee6e4fdd858825b01b9
BLAKE2b-256 checksum
How to use checksums
4297dbc1a3ea77942c8a7c43dd75c6673f3fd69214596f676271e4ef0de19ef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_swi_prolog-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl
Size 40.8 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
7f8ce3c9e8ee008ad95580408b59a26b05ac1b18e20a9d9473f4e5b264187695
BLAKE2b-256 checksum
How to use checksums
75bd04a5bc1d620de1dd1fba500ffa2eed63aa03083ac8155ee37845bb0bdbbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tree-sitter-swi-prolog 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page