tree-sitter-macaulay2 6.3.1__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.
Files changed (31) hide show
  1. tree_sitter_macaulay2-6.3.1/LICENCE +21 -0
  2. tree_sitter_macaulay2-6.3.1/PKG-INFO +143 -0
  3. tree_sitter_macaulay2-6.3.1/README.md +124 -0
  4. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2/__init__.py +46 -0
  5. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2/__init__.pyi +20 -0
  6. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2/binding.c +35 -0
  7. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2/py.typed +0 -0
  8. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/PKG-INFO +143 -0
  9. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/SOURCES.txt +15 -0
  10. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/dependency_links.txt +1 -0
  11. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/not-zip-safe +1 -0
  12. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/requires.txt +3 -0
  13. tree_sitter_macaulay2-6.3.1/bindings/python/tree_sitter_macaulay2.egg-info/top_level.txt +2 -0
  14. tree_sitter_macaulay2-6.3.1/pyproject.toml +29 -0
  15. tree_sitter_macaulay2-6.3.1/queries/folds.scm +14 -0
  16. tree_sitter_macaulay2-6.3.1/queries/highlights.scm +375 -0
  17. tree_sitter_macaulay2-6.3.1/queries/indents.scm +26 -0
  18. tree_sitter_macaulay2-6.3.1/queries/injections.scm +8 -0
  19. tree_sitter_macaulay2-6.3.1/queries/macaulay2/folds.scm +14 -0
  20. tree_sitter_macaulay2-6.3.1/queries/macaulay2/highlights.scm +375 -0
  21. tree_sitter_macaulay2-6.3.1/queries/macaulay2/indents.scm +26 -0
  22. tree_sitter_macaulay2-6.3.1/queries/macaulay2/injections.scm +8 -0
  23. tree_sitter_macaulay2-6.3.1/queries/macaulay2/tags.scm +64 -0
  24. tree_sitter_macaulay2-6.3.1/queries/tags.scm +64 -0
  25. tree_sitter_macaulay2-6.3.1/setup.cfg +4 -0
  26. tree_sitter_macaulay2-6.3.1/setup.py +78 -0
  27. tree_sitter_macaulay2-6.3.1/src/parser.c +126634 -0
  28. tree_sitter_macaulay2-6.3.1/src/scanner.c +1479 -0
  29. tree_sitter_macaulay2-6.3.1/src/tree_sitter/alloc.h +54 -0
  30. tree_sitter_macaulay2-6.3.1/src/tree_sitter/array.h +330 -0
  31. tree_sitter_macaulay2-6.3.1/src/tree_sitter/parser.h +286 -0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Max Brunsfeld
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,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-macaulay2
3
+ Version: 6.3.1
4
+ Summary: Macaulay2 grammar for tree-sitter
5
+ Author-email: Alexander Golys <alexandergolys@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/AlexanderGolys/tree-sitter-macaulay2
8
+ Keywords: incremental,parsing,tree-sitter,macaulay2
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: LICENCE
16
+ Provides-Extra: core
17
+ Requires-Dist: tree-sitter~=0.24; extra == "core"
18
+ Dynamic: license-file
19
+
20
+ # tree-sitter-macaulay2
21
+
22
+ [![release][release]](https://github.com/AlexanderGolys/tree-sitter-macaulay2/releases/latest)
23
+ [![crates][crates]](https://crates.io/crates/tree-sitter-macaulay2)
24
+ [![docs.rs][docs.rs]](https://docs.rs/tree-sitter-macaulay2)
25
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-macaulay2)
26
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-macaulay2)
27
+ [![license][license]](LICENCE)
28
+
29
+ [Macaulay2](https://macaulay2.com/) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
30
+
31
+ <img width="3840" height="2160" alt="Macaulay2 code highlighted with this grammar" src="https://github.com/user-attachments/assets/06c3daba-1785-48fc-93b4-c9171081db05" />
32
+
33
+ The parse tree follows the precedence and newline rules of Macaulay2's own
34
+ parser; [docs/macaulay2-parsing-precedence.md](docs/macaulay2-parsing-precedence.md)
35
+ describes how they are modelled.
36
+
37
+ ## Queries
38
+
39
+ | File | Purpose |
40
+ | ------------------------------------------------- | ------------------------------------------------------------- |
41
+ | [`highlights.scm`](queries/highlights.scm) | Syntax highlighting, see [docs/highlight-queries.md](docs/highlight-queries.md) |
42
+ | [`indents.scm`](queries/indents.scm) | Indentation |
43
+ | [`folds.scm`](queries/folds.scm) | Code folding |
44
+ | [`tags.scm`](queries/tags.scm) | Symbol tags for definitions and method installations |
45
+ | [`injections.scm`](queries/injections.scm) | Language injections |
46
+
47
+ `queries/macaulay2/` holds deprecated copies of the same files and will be
48
+ removed in 7.x.
49
+
50
+ ## Usage
51
+
52
+ ### Rust
53
+
54
+ ```sh
55
+ cargo add tree-sitter tree-sitter-macaulay2
56
+ ```
57
+
58
+ ```rust
59
+ let mut parser = tree_sitter::Parser::new();
60
+ parser.set_language(&tree_sitter_macaulay2::language())?;
61
+ let tree = parser.parse("R = QQ[x, y]", None).unwrap();
62
+ ```
63
+
64
+ ### Node.js
65
+
66
+ ```sh
67
+ npm install tree-sitter tree-sitter-macaulay2
68
+ ```
69
+
70
+ ```js
71
+ import Parser from "tree-sitter";
72
+ import Macaulay2 from "tree-sitter-macaulay2";
73
+
74
+ const parser = new Parser();
75
+ parser.setLanguage(Macaulay2);
76
+ const tree = parser.parse("R = QQ[x, y]");
77
+ ```
78
+
79
+ ### Python
80
+
81
+ ```sh
82
+ pip install tree-sitter tree-sitter-macaulay2
83
+ ```
84
+
85
+ ```python
86
+ from tree_sitter import Language, Parser
87
+ import tree_sitter_macaulay2
88
+
89
+ parser = Parser(Language(tree_sitter_macaulay2.language()))
90
+ tree = parser.parse(b"R = QQ[x, y]")
91
+ ```
92
+
93
+ All bindings also export the queries as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`,
94
+ `TAGS_QUERY`, `INDENTS_QUERY`, and `FOLDS_QUERY`.
95
+
96
+ ### Neovim
97
+
98
+ The parser is not bundled with nvim-treesitter yet. With the `master` branch of
99
+ nvim-treesitter, register it and the `.m2` file type, then run
100
+ `:TSInstall macaulay2`:
101
+
102
+ ```lua
103
+ vim.filetype.add({ extension = { m2 = "macaulay2" } })
104
+
105
+ require("nvim-treesitter.parsers").get_parser_configs().macaulay2 = {
106
+ install_info = {
107
+ url = "https://github.com/AlexanderGolys/tree-sitter-macaulay2",
108
+ files = { "src/parser.c", "src/scanner.c" },
109
+ },
110
+ filetype = "macaulay2",
111
+ }
112
+ ```
113
+
114
+ Neovim reads queries from `queries/macaulay2/` on the runtime path; add a clone
115
+ of this repository to `runtimepath` to use them.
116
+
117
+ ## Development
118
+
119
+ ```sh
120
+ npm install
121
+ npx tree-sitter generate # regenerate src/ from grammar.js
122
+ npx tree-sitter test # corpus and highlight tests
123
+ npm run build:wasm # build tree-sitter-macaulay2.wasm
124
+ ```
125
+
126
+ Part of the corpus is generated from Macaulay2's own parser; see
127
+ [CONTRIBUTING.md](CONTRIBUTING.md) for that workflow and the full set of checks.
128
+
129
+ ## References
130
+
131
+ - [Macaulay2](https://macaulay2.com/)
132
+ - [Parsing precedence in Macaulay2](https://macaulay2.com/doc/Macaulay2/share/doc/Macaulay2/Macaulay2Doc/html/_parsing_spprecedence_cm_spin_spdetail.html)
133
+
134
+ ## License
135
+
136
+ [MIT](LICENCE)
137
+
138
+ [release]: https://img.shields.io/github/v/release/AlexanderGolys/tree-sitter-macaulay2?logo=github
139
+ [crates]: https://img.shields.io/crates/v/tree-sitter-macaulay2?logo=rust
140
+ [docs.rs]: https://img.shields.io/docsrs/tree-sitter-macaulay2?logo=docs.rs
141
+ [npm]: https://img.shields.io/npm/v/tree-sitter-macaulay2?logo=npm
142
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-macaulay2?logo=pypi
143
+ [license]: https://img.shields.io/github/license/AlexanderGolys/tree-sitter-macaulay2
@@ -0,0 +1,124 @@
1
+ # tree-sitter-macaulay2
2
+
3
+ [![release][release]](https://github.com/AlexanderGolys/tree-sitter-macaulay2/releases/latest)
4
+ [![crates][crates]](https://crates.io/crates/tree-sitter-macaulay2)
5
+ [![docs.rs][docs.rs]](https://docs.rs/tree-sitter-macaulay2)
6
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-macaulay2)
7
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-macaulay2)
8
+ [![license][license]](LICENCE)
9
+
10
+ [Macaulay2](https://macaulay2.com/) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
11
+
12
+ <img width="3840" height="2160" alt="Macaulay2 code highlighted with this grammar" src="https://github.com/user-attachments/assets/06c3daba-1785-48fc-93b4-c9171081db05" />
13
+
14
+ The parse tree follows the precedence and newline rules of Macaulay2's own
15
+ parser; [docs/macaulay2-parsing-precedence.md](docs/macaulay2-parsing-precedence.md)
16
+ describes how they are modelled.
17
+
18
+ ## Queries
19
+
20
+ | File | Purpose |
21
+ | ------------------------------------------------- | ------------------------------------------------------------- |
22
+ | [`highlights.scm`](queries/highlights.scm) | Syntax highlighting, see [docs/highlight-queries.md](docs/highlight-queries.md) |
23
+ | [`indents.scm`](queries/indents.scm) | Indentation |
24
+ | [`folds.scm`](queries/folds.scm) | Code folding |
25
+ | [`tags.scm`](queries/tags.scm) | Symbol tags for definitions and method installations |
26
+ | [`injections.scm`](queries/injections.scm) | Language injections |
27
+
28
+ `queries/macaulay2/` holds deprecated copies of the same files and will be
29
+ removed in 7.x.
30
+
31
+ ## Usage
32
+
33
+ ### Rust
34
+
35
+ ```sh
36
+ cargo add tree-sitter tree-sitter-macaulay2
37
+ ```
38
+
39
+ ```rust
40
+ let mut parser = tree_sitter::Parser::new();
41
+ parser.set_language(&tree_sitter_macaulay2::language())?;
42
+ let tree = parser.parse("R = QQ[x, y]", None).unwrap();
43
+ ```
44
+
45
+ ### Node.js
46
+
47
+ ```sh
48
+ npm install tree-sitter tree-sitter-macaulay2
49
+ ```
50
+
51
+ ```js
52
+ import Parser from "tree-sitter";
53
+ import Macaulay2 from "tree-sitter-macaulay2";
54
+
55
+ const parser = new Parser();
56
+ parser.setLanguage(Macaulay2);
57
+ const tree = parser.parse("R = QQ[x, y]");
58
+ ```
59
+
60
+ ### Python
61
+
62
+ ```sh
63
+ pip install tree-sitter tree-sitter-macaulay2
64
+ ```
65
+
66
+ ```python
67
+ from tree_sitter import Language, Parser
68
+ import tree_sitter_macaulay2
69
+
70
+ parser = Parser(Language(tree_sitter_macaulay2.language()))
71
+ tree = parser.parse(b"R = QQ[x, y]")
72
+ ```
73
+
74
+ All bindings also export the queries as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`,
75
+ `TAGS_QUERY`, `INDENTS_QUERY`, and `FOLDS_QUERY`.
76
+
77
+ ### Neovim
78
+
79
+ The parser is not bundled with nvim-treesitter yet. With the `master` branch of
80
+ nvim-treesitter, register it and the `.m2` file type, then run
81
+ `:TSInstall macaulay2`:
82
+
83
+ ```lua
84
+ vim.filetype.add({ extension = { m2 = "macaulay2" } })
85
+
86
+ require("nvim-treesitter.parsers").get_parser_configs().macaulay2 = {
87
+ install_info = {
88
+ url = "https://github.com/AlexanderGolys/tree-sitter-macaulay2",
89
+ files = { "src/parser.c", "src/scanner.c" },
90
+ },
91
+ filetype = "macaulay2",
92
+ }
93
+ ```
94
+
95
+ Neovim reads queries from `queries/macaulay2/` on the runtime path; add a clone
96
+ of this repository to `runtimepath` to use them.
97
+
98
+ ## Development
99
+
100
+ ```sh
101
+ npm install
102
+ npx tree-sitter generate # regenerate src/ from grammar.js
103
+ npx tree-sitter test # corpus and highlight tests
104
+ npm run build:wasm # build tree-sitter-macaulay2.wasm
105
+ ```
106
+
107
+ Part of the corpus is generated from Macaulay2's own parser; see
108
+ [CONTRIBUTING.md](CONTRIBUTING.md) for that workflow and the full set of checks.
109
+
110
+ ## References
111
+
112
+ - [Macaulay2](https://macaulay2.com/)
113
+ - [Parsing precedence in Macaulay2](https://macaulay2.com/doc/Macaulay2/share/doc/Macaulay2/Macaulay2Doc/html/_parsing_spprecedence_cm_spin_spdetail.html)
114
+
115
+ ## License
116
+
117
+ [MIT](LICENCE)
118
+
119
+ [release]: https://img.shields.io/github/v/release/AlexanderGolys/tree-sitter-macaulay2?logo=github
120
+ [crates]: https://img.shields.io/crates/v/tree-sitter-macaulay2?logo=rust
121
+ [docs.rs]: https://img.shields.io/docsrs/tree-sitter-macaulay2?logo=docs.rs
122
+ [npm]: https://img.shields.io/npm/v/tree-sitter-macaulay2?logo=npm
123
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-macaulay2?logo=pypi
124
+ [license]: https://img.shields.io/github/license/AlexanderGolys/tree-sitter-macaulay2
@@ -0,0 +1,46 @@
1
+ """Macaulay2 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 == "TAGS_QUERY":
23
+ return _get_query("TAGS_QUERY", "queries/tags.scm")
24
+ if name == "INDENTS_QUERY":
25
+ return _get_query("INDENTS_QUERY", "queries/indents.scm")
26
+ if name == "FOLDS_QUERY":
27
+ return _get_query("FOLDS_QUERY", "queries/folds.scm")
28
+
29
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
30
+
31
+
32
+ __all__ = [
33
+ "language",
34
+ "HIGHLIGHTS_QUERY",
35
+ "INJECTIONS_QUERY",
36
+ "TAGS_QUERY",
37
+ "INDENTS_QUERY",
38
+ "FOLDS_QUERY",
39
+ ]
40
+
41
+
42
+ def __dir__():
43
+ return sorted(__all__ + [
44
+ "__all__", "__builtins__", "__cached__", "__doc__", "__file__",
45
+ "__loader__", "__name__", "__package__", "__path__", "__spec__",
46
+ ])
@@ -0,0 +1,20 @@
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
+ TAGS_QUERY: Final[str] | None
11
+ """The symbol tagging query for this grammar."""
12
+
13
+ INDENTS_QUERY: Final[str] | None
14
+ """The indentation query for this grammar."""
15
+
16
+ FOLDS_QUERY: Final[str] | None
17
+ """The folding query for this grammar."""
18
+
19
+ def language() -> CapsuleType:
20
+ """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_macaulay2(void);
6
+
7
+ static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
8
+ return PyCapsule_New(tree_sitter_macaulay2(), "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
+ }
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: tree-sitter-macaulay2
3
+ Version: 6.3.1
4
+ Summary: Macaulay2 grammar for tree-sitter
5
+ Author-email: Alexander Golys <alexandergolys@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/AlexanderGolys/tree-sitter-macaulay2
8
+ Keywords: incremental,parsing,tree-sitter,macaulay2
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: LICENCE
16
+ Provides-Extra: core
17
+ Requires-Dist: tree-sitter~=0.24; extra == "core"
18
+ Dynamic: license-file
19
+
20
+ # tree-sitter-macaulay2
21
+
22
+ [![release][release]](https://github.com/AlexanderGolys/tree-sitter-macaulay2/releases/latest)
23
+ [![crates][crates]](https://crates.io/crates/tree-sitter-macaulay2)
24
+ [![docs.rs][docs.rs]](https://docs.rs/tree-sitter-macaulay2)
25
+ [![npm][npm]](https://www.npmjs.com/package/tree-sitter-macaulay2)
26
+ [![pypi][pypi]](https://pypi.org/project/tree-sitter-macaulay2)
27
+ [![license][license]](LICENCE)
28
+
29
+ [Macaulay2](https://macaulay2.com/) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
30
+
31
+ <img width="3840" height="2160" alt="Macaulay2 code highlighted with this grammar" src="https://github.com/user-attachments/assets/06c3daba-1785-48fc-93b4-c9171081db05" />
32
+
33
+ The parse tree follows the precedence and newline rules of Macaulay2's own
34
+ parser; [docs/macaulay2-parsing-precedence.md](docs/macaulay2-parsing-precedence.md)
35
+ describes how they are modelled.
36
+
37
+ ## Queries
38
+
39
+ | File | Purpose |
40
+ | ------------------------------------------------- | ------------------------------------------------------------- |
41
+ | [`highlights.scm`](queries/highlights.scm) | Syntax highlighting, see [docs/highlight-queries.md](docs/highlight-queries.md) |
42
+ | [`indents.scm`](queries/indents.scm) | Indentation |
43
+ | [`folds.scm`](queries/folds.scm) | Code folding |
44
+ | [`tags.scm`](queries/tags.scm) | Symbol tags for definitions and method installations |
45
+ | [`injections.scm`](queries/injections.scm) | Language injections |
46
+
47
+ `queries/macaulay2/` holds deprecated copies of the same files and will be
48
+ removed in 7.x.
49
+
50
+ ## Usage
51
+
52
+ ### Rust
53
+
54
+ ```sh
55
+ cargo add tree-sitter tree-sitter-macaulay2
56
+ ```
57
+
58
+ ```rust
59
+ let mut parser = tree_sitter::Parser::new();
60
+ parser.set_language(&tree_sitter_macaulay2::language())?;
61
+ let tree = parser.parse("R = QQ[x, y]", None).unwrap();
62
+ ```
63
+
64
+ ### Node.js
65
+
66
+ ```sh
67
+ npm install tree-sitter tree-sitter-macaulay2
68
+ ```
69
+
70
+ ```js
71
+ import Parser from "tree-sitter";
72
+ import Macaulay2 from "tree-sitter-macaulay2";
73
+
74
+ const parser = new Parser();
75
+ parser.setLanguage(Macaulay2);
76
+ const tree = parser.parse("R = QQ[x, y]");
77
+ ```
78
+
79
+ ### Python
80
+
81
+ ```sh
82
+ pip install tree-sitter tree-sitter-macaulay2
83
+ ```
84
+
85
+ ```python
86
+ from tree_sitter import Language, Parser
87
+ import tree_sitter_macaulay2
88
+
89
+ parser = Parser(Language(tree_sitter_macaulay2.language()))
90
+ tree = parser.parse(b"R = QQ[x, y]")
91
+ ```
92
+
93
+ All bindings also export the queries as `HIGHLIGHTS_QUERY`, `INJECTIONS_QUERY`,
94
+ `TAGS_QUERY`, `INDENTS_QUERY`, and `FOLDS_QUERY`.
95
+
96
+ ### Neovim
97
+
98
+ The parser is not bundled with nvim-treesitter yet. With the `master` branch of
99
+ nvim-treesitter, register it and the `.m2` file type, then run
100
+ `:TSInstall macaulay2`:
101
+
102
+ ```lua
103
+ vim.filetype.add({ extension = { m2 = "macaulay2" } })
104
+
105
+ require("nvim-treesitter.parsers").get_parser_configs().macaulay2 = {
106
+ install_info = {
107
+ url = "https://github.com/AlexanderGolys/tree-sitter-macaulay2",
108
+ files = { "src/parser.c", "src/scanner.c" },
109
+ },
110
+ filetype = "macaulay2",
111
+ }
112
+ ```
113
+
114
+ Neovim reads queries from `queries/macaulay2/` on the runtime path; add a clone
115
+ of this repository to `runtimepath` to use them.
116
+
117
+ ## Development
118
+
119
+ ```sh
120
+ npm install
121
+ npx tree-sitter generate # regenerate src/ from grammar.js
122
+ npx tree-sitter test # corpus and highlight tests
123
+ npm run build:wasm # build tree-sitter-macaulay2.wasm
124
+ ```
125
+
126
+ Part of the corpus is generated from Macaulay2's own parser; see
127
+ [CONTRIBUTING.md](CONTRIBUTING.md) for that workflow and the full set of checks.
128
+
129
+ ## References
130
+
131
+ - [Macaulay2](https://macaulay2.com/)
132
+ - [Parsing precedence in Macaulay2](https://macaulay2.com/doc/Macaulay2/share/doc/Macaulay2/Macaulay2Doc/html/_parsing_spprecedence_cm_spin_spdetail.html)
133
+
134
+ ## License
135
+
136
+ [MIT](LICENCE)
137
+
138
+ [release]: https://img.shields.io/github/v/release/AlexanderGolys/tree-sitter-macaulay2?logo=github
139
+ [crates]: https://img.shields.io/crates/v/tree-sitter-macaulay2?logo=rust
140
+ [docs.rs]: https://img.shields.io/docsrs/tree-sitter-macaulay2?logo=docs.rs
141
+ [npm]: https://img.shields.io/npm/v/tree-sitter-macaulay2?logo=npm
142
+ [pypi]: https://img.shields.io/pypi/v/tree-sitter-macaulay2?logo=pypi
143
+ [license]: https://img.shields.io/github/license/AlexanderGolys/tree-sitter-macaulay2
@@ -0,0 +1,15 @@
1
+ LICENCE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ bindings/python/tree_sitter_macaulay2/__init__.py
6
+ bindings/python/tree_sitter_macaulay2/__init__.pyi
7
+ bindings/python/tree_sitter_macaulay2/binding.c
8
+ bindings/python/tree_sitter_macaulay2/py.typed
9
+ bindings/python/tree_sitter_macaulay2.egg-info/PKG-INFO
10
+ bindings/python/tree_sitter_macaulay2.egg-info/SOURCES.txt
11
+ bindings/python/tree_sitter_macaulay2.egg-info/dependency_links.txt
12
+ bindings/python/tree_sitter_macaulay2.egg-info/not-zip-safe
13
+ bindings/python/tree_sitter_macaulay2.egg-info/requires.txt
14
+ bindings/python/tree_sitter_macaulay2.egg-info/top_level.txt
15
+ src/parser.c
@@ -0,0 +1,2 @@
1
+ _binding
2
+ tree_sitter_macaulay2
@@ -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-macaulay2"
7
+ description = "Macaulay2 grammar for tree-sitter"
8
+ version = "6.3.1"
9
+ keywords = ["incremental", "parsing", "tree-sitter", "macaulay2"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Compilers",
13
+ "Topic :: Text Processing :: Linguistic",
14
+ "Typing :: Typed",
15
+ ]
16
+ authors = [{ name = "Alexander Golys", email = "alexandergolys@gmail.com" }]
17
+ requires-python = ">=3.10"
18
+ license.text = "MIT"
19
+ readme = "README.md"
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/AlexanderGolys/tree-sitter-macaulay2"
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,14 @@
1
+ [
2
+ (list)
3
+ (sequence)
4
+ (parenthesized_expression)
5
+ (array)
6
+ (angle_bar_list)
7
+ (cell)
8
+ (lambda_expression)
9
+ (if_statement)
10
+ (for_loop)
11
+ (while_loop)
12
+ (try_statement)
13
+ (new_statement)
14
+ ] @fold