tree-sitter-macaulay2
Macaulay2 grammar for tree-sitter.
The parse tree follows the precedence and newline rules of Macaulay2's own parser; docs/macaulay2-parsing-precedence.md describes how they are modelled.
Queries
| File | Purpose |
|---|---|
highlights.scm |
Syntax highlighting, see docs/highlight-queries.md |
indents.scm |
Indentation |
folds.scm |
Code folding |
tags.scm |
Symbol tags for definitions and method installations |
injections.scm |
Language injections |
queries/macaulay2/ holds deprecated copies of the same files and will be
removed in 7.x.
Usage
Rust
cargo add tree-sitter tree-sitter-macaulay2
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_macaulay2::language())?;
let tree = parser.parse("R = QQ[x, y]", None).unwrap();
Node.js
npm install tree-sitter tree-sitter-macaulay2
import Parser from "tree-sitter";
import Macaulay2 from "tree-sitter-macaulay2";
const parser = new Parser();
parser.setLanguage(Macaulay2);
const tree = parser.parse("R = QQ[x, y]");
Python
pip install tree-sitter tree-sitter-macaulay2
from tree_sitter import Language, Parser
import tree_sitter_macaulay2
parser = Parser(Language(tree_sitter_macaulay2.language()))
tree = parser.parse(b"R = QQ[x, y]")
All bindings also export the queries as HIGHLIGHTS_QUERY, INJECTIONS_QUERY,
TAGS_QUERY, INDENTS_QUERY, and FOLDS_QUERY.
Neovim
The parser is not bundled with nvim-treesitter yet. With the master branch of
nvim-treesitter, register it and the .m2 file type, then run
:TSInstall macaulay2:
vim.filetype.add({ extension = { m2 = "macaulay2" } })
require("nvim-treesitter.parsers").get_parser_configs().macaulay2 = {
install_info = {
url = "https://github.com/AlexanderGolys/tree-sitter-macaulay2",
files = { "src/parser.c", "src/scanner.c" },
},
filetype = "macaulay2",
}
Neovim reads queries from queries/macaulay2/ on the runtime path; add a clone
of this repository to runtimepath to use them.
Development
npm install
npx tree-sitter generate # regenerate src/ from grammar.js
npx tree-sitter test # corpus and highlight tests
npm run build:wasm # build tree-sitter-macaulay2.wasm
Part of the corpus is generated from Macaulay2's own parser; see CONTRIBUTING.md for that workflow and the full set of checks.
References
License
Metadata
Release files for tree-sitter-macaulay2 6.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tree_sitter_macaulay2-6.3.1.tar.gz | 157.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tree_sitter_macaulay2-6.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 271.8 kB
Release files / tree_sitter_macaulay2-6.3.1.tar.gz
| Download URL | tree_sitter_macaulay2-6.3.1.tar.gz |
|---|---|
| Size | 157.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99c834010d3d38b2026691f5b5496fc472c298151fc171353cdf439910a229e0
|
|
BLAKE2b-256 checksum How to use checksums |
670c3f2c06da068f0b870a808c2e6159931079686f15ed27f5e5035371ab0a5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / tree_sitter_macaulay2-6.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tree_sitter_macaulay2-6.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 114.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ae71a0b09cce7c46af0addeafec5eaa92fe10e097bd7070a638e6015f8cccb24
|
|
BLAKE2b-256 checksum How to use checksums |
c789051a4b3fd9d0fc7641374f784ed5ba4c42ba52fdb15e3695f8e4154adabb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|