Q# grammar for tree-sitter
Project description
tree-sitter-qsharp
A tree-sitter grammar for Q#, Microsoft's quantum programming language.
This is a new project, not affiliated with Microsoft or the tree-sitter organization. Feedback, bug reports, and contributions are welcome.
What it does
Parses Q# source files into a concrete syntax tree that editors can use for syntax highlighting, code folding, symbol navigation, and indentation.
Built by reading the Q# language reference and the Q# compiler source. Tested against Q# files in the microsoft/qsharp repository.
Supported constructs
- Namespaces, imports, exports, open directives
- Operations and functions with type parameters, functor clauses, specializations
- Structs, newtypes, all builtin types
- Full expression grammar with operator precedence per the official specification
- Quantum-specific syntax:
use/borrow,within/apply,repeat/until/fixup,Adjoint/Controlled - All literals: int, bigint, float, imaginary, string, interpolated string, bool, Result, Pauli
- External scanner for float/range disambiguation (
1.vs0..5)
Known limitations
- Explicit type arguments on calls (
Foo<Int>(x)) are not supported due to</>ambiguity with comparison operators. Q# type inference handles this in practice. - Open-ended step ranges (
...2...) parse but the AST does not perfectly represent all range component positions. - This is a v0.x project. There may be edge cases that are not yet covered.
Editor query files
| Feature | File |
|---|---|
| Syntax highlighting | queries/highlights.scm |
| Code folding | queries/folds.scm |
| Symbol outline | queries/tags.scm |
| Auto-indentation | queries/indents.scm |
| Scope tracking | queries/locals.scm |
| Text objects | queries/textobjects.scm |
Capture names follow the nvim-treesitter conventions.
Contributing
If you find Q# code that doesn't parse correctly, please open an issue with the .qs file or a minimal reproducing snippet. Pull requests are welcome.
References
- Q# overview
- microsoft/qsharp — Q# compiler and standard library (MIT)
- tree-sitter — parser generator
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree_sitter_qsharp-0.1.2.tar.gz.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2.tar.gz
- Upload date:
- Size: 125.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ba6c3acab7044c4c0391b800ddf3684c9b1605a31b0f82a14f5f47bb5686eb0
|
|
| MD5 |
4c25d94c0a728a5927c0125647206f4a
|
|
| BLAKE2b-256 |
5895291e60e4fe711385beacef35921ef5ed4bb70185ee0c1d04ac8ad52efb57
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 46.8 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7d2daec12d6f39798ca97100806f467d79fb0a7b4ac7c4eb97d29883e04ce9e
|
|
| MD5 |
b2788b8e34747da0675644632f27c7f3
|
|
| BLAKE2b-256 |
96345f4ec46188ba0529ed41679578fcd11d054c23eaa495aba33e6965c87154
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 48.4 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a77dff4454a574b9e12735cf25efcc832c100b51878c74a1f4feaae4c6518d7
|
|
| MD5 |
74c7062ef2e0b9e785e7fdfc85419a4f
|
|
| BLAKE2b-256 |
5afa8243af0cacc869905cfb768b95376d0750ce9eb4e888c78ec3d2263350ec
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 64.5 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7cf3feb79c867792815deadae0b3b63c7e285d23e0cacc5dc93bdcb941db44d
|
|
| MD5 |
78e157d3fdfe5a5db418a67bfe7b822e
|
|
| BLAKE2b-256 |
fae0b65536b7ac0d719e928cc9efebb9287b43d46ef0ed7cc3375574b7916b3b
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 68.9 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f0d30346ecd21180ba7eab210625c22de728c94ecfffc34333642fb832f5e2
|
|
| MD5 |
c8fc61b7a938967e4394462f7351f7f6
|
|
| BLAKE2b-256 |
266530d86592ec64b40f6cd7a0b27bfb02432d87524e6085135a29f6a755b1a5
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 69.9 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af624b0fe12f4f6c8daa2d07ac27ef29e59963de8fb89fa6507c4d52570faa1e
|
|
| MD5 |
8c7596dc8acd64c92cffc748770566dc
|
|
| BLAKE2b-256 |
2fe5c5e94a055d3c976ef078300689bdd51bb4978c5fd135dfe70c1e98e6e251
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 64.6 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcc31c559587c55663d03b57206a3942c29bf5c98e434d44cc7ece30bc612fae
|
|
| MD5 |
2be98de34ada2958742b6b22e095d255
|
|
| BLAKE2b-256 |
4e6d3b879ae4270211d6375318528e538b345ae6ca91a5479d23aae1a98be43f
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 48.4 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da5c2a5b3a713b8c3eac9e5cfeb0677d7858dfa3d64b2a0b6a24112f227a2e2
|
|
| MD5 |
71bc5ff1cb8ece9d603a09a1048ea755
|
|
| BLAKE2b-256 |
55a5f3f171886310ca96bd99ece39b4c5cf67800a74bb589c99b60a1c9807892
|
File details
Details for the file tree_sitter_qsharp-0.1.2-cp310-abi3-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_qsharp-0.1.2-cp310-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 45.9 kB
- Tags: CPython 3.10+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba7b57ea299a63c2efdfe940e6daec531fd47cdbe0789abe3271e3971cccf106
|
|
| MD5 |
1a3bd9431e0495f89108744407e02208
|
|
| BLAKE2b-256 |
7aec32eaf62bd2e372ad2ac24521f503eb8d2e538fdd540cd6bcd3ab9876d5ac
|