tree-sitter-qsharp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tree_sitter_qsharp-0.1.0/LICENSE +21 -0
- tree_sitter_qsharp-0.1.0/PKG-INFO +99 -0
- tree_sitter_qsharp-0.1.0/README.md +80 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp/__init__.py +43 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp/__init__.pyi +17 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp/binding.c +35 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp/py.typed +0 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/PKG-INFO +99 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/SOURCES.txt +15 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/dependency_links.txt +1 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/not-zip-safe +1 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/requires.txt +3 -0
- tree_sitter_qsharp-0.1.0/bindings/python/tree_sitter_qsharp.egg-info/top_level.txt +2 -0
- tree_sitter_qsharp-0.1.0/pyproject.toml +29 -0
- tree_sitter_qsharp-0.1.0/queries/folds.scm +18 -0
- tree_sitter_qsharp-0.1.0/queries/highlights.scm +220 -0
- tree_sitter_qsharp-0.1.0/queries/indents.scm +18 -0
- tree_sitter_qsharp-0.1.0/queries/locals.scm +34 -0
- tree_sitter_qsharp-0.1.0/queries/tags.scm +35 -0
- tree_sitter_qsharp-0.1.0/queries/textobjects.scm +30 -0
- tree_sitter_qsharp-0.1.0/setup.cfg +4 -0
- tree_sitter_qsharp-0.1.0/setup.py +77 -0
- tree_sitter_qsharp-0.1.0/src/parser.c +58897 -0
- tree_sitter_qsharp-0.1.0/src/tree_sitter/alloc.h +54 -0
- tree_sitter_qsharp-0.1.0/src/tree_sitter/array.h +330 -0
- tree_sitter_qsharp-0.1.0/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bezpechno
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-qsharp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Q# grammar for tree-sitter
|
|
5
|
+
Author: bezpechno
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bezpechno/tree-sitter-qsharp
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,qsharp
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: core
|
|
17
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# tree-sitter-qsharp
|
|
21
|
+
|
|
22
|
+
A [tree-sitter](https://tree-sitter.github.io/) grammar for [Q#](https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk), Microsoft's quantum programming language.
|
|
23
|
+
|
|
24
|
+
This is a new project, not affiliated with Microsoft or the tree-sitter organization. Feedback, bug reports, and contributions are welcome.
|
|
25
|
+
|
|
26
|
+
## What it does
|
|
27
|
+
|
|
28
|
+
Parses Q# source files into a concrete syntax tree that editors can use for syntax highlighting, code folding, symbol navigation, and indentation.
|
|
29
|
+
|
|
30
|
+
Built by reading the [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/) and the [Q# compiler source](https://github.com/microsoft/qsharp) as reference. Tested against the Q# files in the microsoft/qsharp repository.
|
|
31
|
+
|
|
32
|
+
### Supported constructs
|
|
33
|
+
|
|
34
|
+
- Namespaces, imports, exports, open directives
|
|
35
|
+
- Operations and functions with type parameters, functor clauses, specializations
|
|
36
|
+
- Structs, newtypes, all builtin types
|
|
37
|
+
- Full expression grammar with operator precedence per the [Q# specification](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/expressions/precedenceandassociativity)
|
|
38
|
+
- Quantum-specific syntax: `use`/`borrow`, `within`/`apply`, `repeat`/`until`/`fixup`, `Adjoint`/`Controlled`
|
|
39
|
+
- All literals: int, bigint, float, imaginary, string, interpolated string, bool, Result, Pauli
|
|
40
|
+
- External scanner for float/range disambiguation (`1.` vs `0..5`)
|
|
41
|
+
|
|
42
|
+
### Known limitations
|
|
43
|
+
|
|
44
|
+
- Explicit type arguments on calls (`Foo<Int>(x)`) are not supported due to `<`/`>` ambiguity with comparison operators. Q# type inference handles this in practice.
|
|
45
|
+
- Open-ended step ranges (`...2...`) parse but the AST does not perfectly represent all range component positions.
|
|
46
|
+
- This is a v0.x project. There may be edge cases that are not yet covered.
|
|
47
|
+
|
|
48
|
+
## Editor query files
|
|
49
|
+
|
|
50
|
+
| Feature | File |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Syntax highlighting | `queries/highlights.scm` |
|
|
53
|
+
| Code folding | `queries/folds.scm` |
|
|
54
|
+
| Symbol outline | `queries/tags.scm` |
|
|
55
|
+
| Auto-indentation | `queries/indents.scm` |
|
|
56
|
+
| Scope tracking | `queries/locals.scm` |
|
|
57
|
+
| Text objects | `queries/textobjects.scm` |
|
|
58
|
+
|
|
59
|
+
Capture names follow the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md) conventions.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install tree-sitter-qsharp # Node.js
|
|
65
|
+
cargo add tree-sitter-qsharp # Rust
|
|
66
|
+
pip install tree-sitter-qsharp # Python
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or from source:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/bezpechno/tree-sitter-qsharp
|
|
73
|
+
cd tree-sitter-qsharp
|
|
74
|
+
tree-sitter generate
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
tree-sitter generate # regenerate parser
|
|
81
|
+
tree-sitter test # run corpus tests
|
|
82
|
+
tree-sitter fuzz # fuzz test
|
|
83
|
+
tree-sitter parse file.qs # parse a file
|
|
84
|
+
tree-sitter highlight file.qs # preview highlighting
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/)
|
|
94
|
+
- [microsoft/qsharp](https://github.com/microsoft/qsharp) — Q# compiler and standard library (MIT)
|
|
95
|
+
- [tree-sitter](https://tree-sitter.github.io/tree-sitter/) — parser generator
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# tree-sitter-qsharp
|
|
2
|
+
|
|
3
|
+
A [tree-sitter](https://tree-sitter.github.io/) grammar for [Q#](https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk), Microsoft's quantum programming language.
|
|
4
|
+
|
|
5
|
+
This is a new project, not affiliated with Microsoft or the tree-sitter organization. Feedback, bug reports, and contributions are welcome.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
Parses Q# source files into a concrete syntax tree that editors can use for syntax highlighting, code folding, symbol navigation, and indentation.
|
|
10
|
+
|
|
11
|
+
Built by reading the [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/) and the [Q# compiler source](https://github.com/microsoft/qsharp) as reference. Tested against the Q# files in the microsoft/qsharp repository.
|
|
12
|
+
|
|
13
|
+
### Supported constructs
|
|
14
|
+
|
|
15
|
+
- Namespaces, imports, exports, open directives
|
|
16
|
+
- Operations and functions with type parameters, functor clauses, specializations
|
|
17
|
+
- Structs, newtypes, all builtin types
|
|
18
|
+
- Full expression grammar with operator precedence per the [Q# specification](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/expressions/precedenceandassociativity)
|
|
19
|
+
- Quantum-specific syntax: `use`/`borrow`, `within`/`apply`, `repeat`/`until`/`fixup`, `Adjoint`/`Controlled`
|
|
20
|
+
- All literals: int, bigint, float, imaginary, string, interpolated string, bool, Result, Pauli
|
|
21
|
+
- External scanner for float/range disambiguation (`1.` vs `0..5`)
|
|
22
|
+
|
|
23
|
+
### Known limitations
|
|
24
|
+
|
|
25
|
+
- Explicit type arguments on calls (`Foo<Int>(x)`) are not supported due to `<`/`>` ambiguity with comparison operators. Q# type inference handles this in practice.
|
|
26
|
+
- Open-ended step ranges (`...2...`) parse but the AST does not perfectly represent all range component positions.
|
|
27
|
+
- This is a v0.x project. There may be edge cases that are not yet covered.
|
|
28
|
+
|
|
29
|
+
## Editor query files
|
|
30
|
+
|
|
31
|
+
| Feature | File |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Syntax highlighting | `queries/highlights.scm` |
|
|
34
|
+
| Code folding | `queries/folds.scm` |
|
|
35
|
+
| Symbol outline | `queries/tags.scm` |
|
|
36
|
+
| Auto-indentation | `queries/indents.scm` |
|
|
37
|
+
| Scope tracking | `queries/locals.scm` |
|
|
38
|
+
| Text objects | `queries/textobjects.scm` |
|
|
39
|
+
|
|
40
|
+
Capture names follow the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md) conventions.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install tree-sitter-qsharp # Node.js
|
|
46
|
+
cargo add tree-sitter-qsharp # Rust
|
|
47
|
+
pip install tree-sitter-qsharp # Python
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or from source:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/bezpechno/tree-sitter-qsharp
|
|
54
|
+
cd tree-sitter-qsharp
|
|
55
|
+
tree-sitter generate
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Development
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
tree-sitter generate # regenerate parser
|
|
62
|
+
tree-sitter test # run corpus tests
|
|
63
|
+
tree-sitter fuzz # fuzz test
|
|
64
|
+
tree-sitter parse file.qs # parse a file
|
|
65
|
+
tree-sitter highlight file.qs # preview highlighting
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
## References
|
|
73
|
+
|
|
74
|
+
- [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/)
|
|
75
|
+
- [microsoft/qsharp](https://github.com/microsoft/qsharp) — Q# compiler and standard library (MIT)
|
|
76
|
+
- [tree-sitter](https://tree-sitter.github.io/tree-sitter/) — parser generator
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Q# grammar for tree-sitter"""
|
|
2
|
+
|
|
3
|
+
from importlib.resources import files as _files
|
|
4
|
+
|
|
5
|
+
from ._binding import language
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _get_query(name, file):
|
|
9
|
+
try:
|
|
10
|
+
query = _files(f"{__package__}") / file
|
|
11
|
+
globals()[name] = query.read_text()
|
|
12
|
+
except FileNotFoundError:
|
|
13
|
+
globals()[name] = None
|
|
14
|
+
return globals()[name]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __getattr__(name):
|
|
18
|
+
if name == "HIGHLIGHTS_QUERY":
|
|
19
|
+
return _get_query("HIGHLIGHTS_QUERY", "queries/highlights.scm")
|
|
20
|
+
if name == "INJECTIONS_QUERY":
|
|
21
|
+
return _get_query("INJECTIONS_QUERY", "queries/injections.scm")
|
|
22
|
+
if name == "LOCALS_QUERY":
|
|
23
|
+
return _get_query("LOCALS_QUERY", "queries/locals.scm")
|
|
24
|
+
if name == "TAGS_QUERY":
|
|
25
|
+
return _get_query("TAGS_QUERY", "queries/tags.scm")
|
|
26
|
+
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"language",
|
|
32
|
+
"HIGHLIGHTS_QUERY",
|
|
33
|
+
"INJECTIONS_QUERY",
|
|
34
|
+
"LOCALS_QUERY",
|
|
35
|
+
"TAGS_QUERY",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def __dir__():
|
|
40
|
+
return sorted(__all__ + [
|
|
41
|
+
"__all__", "__builtins__", "__cached__", "__doc__", "__file__",
|
|
42
|
+
"__loader__", "__name__", "__package__", "__path__", "__spec__",
|
|
43
|
+
])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
from typing_extensions import CapsuleType
|
|
3
|
+
|
|
4
|
+
HIGHLIGHTS_QUERY: Final[str] | None
|
|
5
|
+
"""The syntax highlighting query for this grammar."""
|
|
6
|
+
|
|
7
|
+
INJECTIONS_QUERY: Final[str] | None
|
|
8
|
+
"""The language injection query for this grammar."""
|
|
9
|
+
|
|
10
|
+
LOCALS_QUERY: Final[str] | None
|
|
11
|
+
"""The local variable query for this grammar."""
|
|
12
|
+
|
|
13
|
+
TAGS_QUERY: Final[str] | None
|
|
14
|
+
"""The symbol tagging query for this grammar."""
|
|
15
|
+
|
|
16
|
+
def language() -> CapsuleType:
|
|
17
|
+
"""The tree-sitter language function for this grammar."""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_qsharp(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_qsharp(), "tree_sitter.Language", NULL);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static struct PyModuleDef_Slot slots[] = {
|
|
12
|
+
#ifdef Py_GIL_DISABLED
|
|
13
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
14
|
+
#endif
|
|
15
|
+
{0, NULL}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static PyMethodDef methods[] = {
|
|
19
|
+
{"language", _binding_language, METH_NOARGS,
|
|
20
|
+
"Get the tree-sitter language for this grammar."},
|
|
21
|
+
{NULL, NULL, 0, NULL}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static struct PyModuleDef module = {
|
|
25
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
|
26
|
+
.m_name = "_binding",
|
|
27
|
+
.m_doc = NULL,
|
|
28
|
+
.m_size = 0,
|
|
29
|
+
.m_methods = methods,
|
|
30
|
+
.m_slots = slots,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
PyMODINIT_FUNC PyInit__binding(void) {
|
|
34
|
+
return PyModuleDef_Init(&module);
|
|
35
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-qsharp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Q# grammar for tree-sitter
|
|
5
|
+
Author: bezpechno
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bezpechno/tree-sitter-qsharp
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,qsharp
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: core
|
|
17
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# tree-sitter-qsharp
|
|
21
|
+
|
|
22
|
+
A [tree-sitter](https://tree-sitter.github.io/) grammar for [Q#](https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk), Microsoft's quantum programming language.
|
|
23
|
+
|
|
24
|
+
This is a new project, not affiliated with Microsoft or the tree-sitter organization. Feedback, bug reports, and contributions are welcome.
|
|
25
|
+
|
|
26
|
+
## What it does
|
|
27
|
+
|
|
28
|
+
Parses Q# source files into a concrete syntax tree that editors can use for syntax highlighting, code folding, symbol navigation, and indentation.
|
|
29
|
+
|
|
30
|
+
Built by reading the [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/) and the [Q# compiler source](https://github.com/microsoft/qsharp) as reference. Tested against the Q# files in the microsoft/qsharp repository.
|
|
31
|
+
|
|
32
|
+
### Supported constructs
|
|
33
|
+
|
|
34
|
+
- Namespaces, imports, exports, open directives
|
|
35
|
+
- Operations and functions with type parameters, functor clauses, specializations
|
|
36
|
+
- Structs, newtypes, all builtin types
|
|
37
|
+
- Full expression grammar with operator precedence per the [Q# specification](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/expressions/precedenceandassociativity)
|
|
38
|
+
- Quantum-specific syntax: `use`/`borrow`, `within`/`apply`, `repeat`/`until`/`fixup`, `Adjoint`/`Controlled`
|
|
39
|
+
- All literals: int, bigint, float, imaginary, string, interpolated string, bool, Result, Pauli
|
|
40
|
+
- External scanner for float/range disambiguation (`1.` vs `0..5`)
|
|
41
|
+
|
|
42
|
+
### Known limitations
|
|
43
|
+
|
|
44
|
+
- Explicit type arguments on calls (`Foo<Int>(x)`) are not supported due to `<`/`>` ambiguity with comparison operators. Q# type inference handles this in practice.
|
|
45
|
+
- Open-ended step ranges (`...2...`) parse but the AST does not perfectly represent all range component positions.
|
|
46
|
+
- This is a v0.x project. There may be edge cases that are not yet covered.
|
|
47
|
+
|
|
48
|
+
## Editor query files
|
|
49
|
+
|
|
50
|
+
| Feature | File |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Syntax highlighting | `queries/highlights.scm` |
|
|
53
|
+
| Code folding | `queries/folds.scm` |
|
|
54
|
+
| Symbol outline | `queries/tags.scm` |
|
|
55
|
+
| Auto-indentation | `queries/indents.scm` |
|
|
56
|
+
| Scope tracking | `queries/locals.scm` |
|
|
57
|
+
| Text objects | `queries/textobjects.scm` |
|
|
58
|
+
|
|
59
|
+
Capture names follow the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md) conventions.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install tree-sitter-qsharp # Node.js
|
|
65
|
+
cargo add tree-sitter-qsharp # Rust
|
|
66
|
+
pip install tree-sitter-qsharp # Python
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or from source:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/bezpechno/tree-sitter-qsharp
|
|
73
|
+
cd tree-sitter-qsharp
|
|
74
|
+
tree-sitter generate
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
tree-sitter generate # regenerate parser
|
|
81
|
+
tree-sitter test # run corpus tests
|
|
82
|
+
tree-sitter fuzz # fuzz test
|
|
83
|
+
tree-sitter parse file.qs # parse a file
|
|
84
|
+
tree-sitter highlight file.qs # preview highlighting
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- [Q# language documentation](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/)
|
|
94
|
+
- [microsoft/qsharp](https://github.com/microsoft/qsharp) — Q# compiler and standard library (MIT)
|
|
95
|
+
- [tree-sitter](https://tree-sitter.github.io/tree-sitter/) — parser generator
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
bindings/python/tree_sitter_qsharp/__init__.py
|
|
6
|
+
bindings/python/tree_sitter_qsharp/__init__.pyi
|
|
7
|
+
bindings/python/tree_sitter_qsharp/binding.c
|
|
8
|
+
bindings/python/tree_sitter_qsharp/py.typed
|
|
9
|
+
bindings/python/tree_sitter_qsharp.egg-info/PKG-INFO
|
|
10
|
+
bindings/python/tree_sitter_qsharp.egg-info/SOURCES.txt
|
|
11
|
+
bindings/python/tree_sitter_qsharp.egg-info/dependency_links.txt
|
|
12
|
+
bindings/python/tree_sitter_qsharp.egg-info/not-zip-safe
|
|
13
|
+
bindings/python/tree_sitter_qsharp.egg-info/requires.txt
|
|
14
|
+
bindings/python/tree_sitter_qsharp.egg-info/top_level.txt
|
|
15
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=62.4.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-qsharp"
|
|
7
|
+
description = "Q# grammar for tree-sitter"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "qsharp"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "bezpechno" }]
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
license.text = "MIT"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/bezpechno/tree-sitter-qsharp"
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
core = ["tree-sitter~=0.24"]
|
|
26
|
+
|
|
27
|
+
[tool.cibuildwheel]
|
|
28
|
+
build = "cp310-*"
|
|
29
|
+
build-frontend = "build"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
; folds.scm — Code folding regions for Q#
|
|
2
|
+
|
|
3
|
+
(block) @fold
|
|
4
|
+
(namespace) @fold
|
|
5
|
+
(callable_decl) @fold
|
|
6
|
+
(struct_decl) @fold
|
|
7
|
+
(newtype_decl) @fold
|
|
8
|
+
(specialization_list) @fold
|
|
9
|
+
(specialization) @fold
|
|
10
|
+
(if_expression) @fold
|
|
11
|
+
(elif_clause) @fold
|
|
12
|
+
(else_clause) @fold
|
|
13
|
+
(for_expression) @fold
|
|
14
|
+
(while_expression) @fold
|
|
15
|
+
(repeat_expression) @fold
|
|
16
|
+
(conjugation_expression) @fold
|
|
17
|
+
(array_expression) @fold
|
|
18
|
+
(param_list) @fold
|