Skip to main content

tree-sitter-macaulay2

release crates docs.rs npm pypi license

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

MIT

Metadata

Release files for tree-sitter-macaulay2 6.3.2

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-macaulay2 6.3.2
File Size Uploaded
tree_sitter_macaulay2-6.3.2.tar.gz 157.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tree-sitter-macaulay2 6.3.2
File Interpreter ABI Platform
tree_sitter_macaulay2-6.3.2-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.6 kB

Release files / tree_sitter_macaulay2-6.3.2.tar.gz

Download URL tree_sitter_macaulay2-6.3.2.tar.gz
Size 157.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ab296e479c53be09757f772175a2a4bc2de3091d56c4b6fc20630e514ca0dbc6
BLAKE2b-256 checksum
How to use checksums
aad50d963f3863420d364ed069bfa7fb290b66fd30eefb440adacceb2f8c27b3
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.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tree_sitter_macaulay2-6.3.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 114.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3764e096ae61a86b788410ff9560e3d30f637befb3d93a203a46173e7070eadd
BLAKE2b-256 checksum
How to use checksums
5c4a78c9c8d86fb0d4e69859dd56db062b7de361038f4d643f481abeb96c617a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

6.3.2 This release

2 release files

6.3.1

2 release files

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