Skip to main content

tree-sitter-gram

A tree-sitter grammar for gram notation.

About Gram

Gram is a pattern-based notation for structured data.

Patterns and Subjects

A pattern is a generic data structure with a value and nested elements:

interface Pattern<V> {
  value: V;
  elements: Pattern<V>[];
}

Gram patterns are always Pattern<Subject> — patterns where values are subjects. A subject is content combining an optional identifier, labels, and/or a record of properties.

Pattern Elements

The gram_pattern (top-level structure) consists of a sequence of patterns. Syntactically, subject_pattern, node_pattern, relationship_pattern, and annotated_pattern are peers.

They correlate to the underlying data structure based on the number of elements:

  • Node Pattern (): A pattern with 0 elements.
  • Annotated Pattern @a (b): A pattern with 1 element.
  • Relationship Pattern (a)-->(b): A pattern with 2 elements.
  • Subject Pattern [ s | ... ]: A pattern with an arbitrary number of elements.

Path Flattening

A path is a flattened tree of relationships. For example:

(a)-[r1]->(b)-[r2]->(c) 
// is equivalent to:
[ | [r1 | (a), (b)], [r2 | (b),(c)] ]

Subject Pattern Notation

The subject pattern notation uses [ subject | elements ] to explicitly show pattern structure:

// A team with members as elements
[devrel:Team {name: "Developer Relations"} | abk, adam, alex]

// A simple atomic pattern (no elements)
[:Person {name: "Andreas", roles: ["author"]}]

Node Notation (Syntactic Sugar)

Parentheses ( subject ) provide familiar graph node syntax:

()                           // Empty node
(a)                          // Node with identifier
(a:Person)                   // Node with identifier and label
(a:Person {name: "Alice"})   // Node with identifier, label, and properties

Relationship Notation (Syntactic Sugar)

Arrows connect nodes to express graph relationships:

// Path notation for graph relationships
(a:Person)-[:KNOWS]->(b:Person)

// Subject Pattern notation can contain path patterns
[social:Graph | 
  (a:Person {name: "Alice"}),
  (b:Person {name: "Bob"}),
  (a)-[:KNOWS]->(b)
]

Comments

Gram files support comments using // syntax:

// This is a line comment
(hello)-->(world)  // End-of-line comment

Documentation comments use /** ... */ and parse as a doc_comment node. Editors inject the gramdoc language into them (see queries/injections.scm):

/**
 * A human individual.
 *
 * @property name The full name of the person.
 */
(Person {name: "STRING!"})

A doc comment may appear anywhere a // comment may, including inside records and between pattern elements. Plain /* ... */ block comments are not supported, and /**/ is not a doc comment.

Learn more about gram at the gram-data github org.

Editor Support

This repository includes editor integrations for syntax highlighting and language support:

  • Zed Editor - Full syntax highlighting and language support
  • More editors coming soon! Contributions welcome.

See editors/README.md for installation instructions and available features.

Language Bindings

Tree-sitter bindings are available for multiple languages:

  • Node.js: npm install @gram-data/tree-sitter-gram
  • Rust: Available via Cargo.toml
  • Python: Install via pip install .
  • Go: Import from this repository
  • Swift: Available via Swift Package Manager
  • C: Build with included Makefile

Development

Generate the parser after grammar changes:

npx tree-sitter generate
npx tree-sitter test

Run language binding tests:

npm test                    # Node.js bindings
cargo test                  # Rust bindings
python -m pytest           # Python bindings
make test                   # C bindings

See DEVELOP.md for detailed development guidelines.

Metadata

Release files for tree-sitter-gram 0.5.0

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-gram 0.5.0
File Size Uploaded Provenance Actions
tree_sitter_gram-0.5.0.tar.gz 20.2 kB Without provenance Details for tree_sitter_gram-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-gram 0.5.0
File Actions
tree_sitter_gram-0.5.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for tree_sitter_gram-0.5.0-cp39-abi3-win_arm64.whl
tree_sitter_gram-0.5.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for tree_sitter_gram-0.5.0-cp39-abi3-win_amd64.whl
tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
tree_sitter_gram-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details for tree_sitter_gram-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_gram-0.5.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.9 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_gram-0.5.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_gram-0.5.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for tree_sitter_gram-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
tree_sitter_gram-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl CPython 3.9 abi3 macOS 10.9+ x86-64 Details for tree_sitter_gram-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl

Total release size: 234.2 kB

Release files / tree_sitter_gram-0.5.0.tar.gz

Download URL tree_sitter_gram-0.5.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5d3af98ef311f00ab9b3096fa0177517578038c51888a66d69dd87f41a98fbed
BLAKE2b-256 checksum
How to use checksums
dc625158da865ea31b71ba062f962302250498a775339e0117de1b0a1b17e7c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-win_arm64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-win_arm64.whl
Size 20.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
60407416e356b5356be735f5e236851990fc24c26c8f7797501bb96f9cc4cb16
BLAKE2b-256 checksum
How to use checksums
b8adc5b82d17c295fd658c1fbe7687d992f8248b8ccf561b249ea72440aa6f17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-win_amd64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-win_amd64.whl
Size 20.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0402d6a0b6a4b55c60d5b4cf197cceab3e3c04fd01e95912f74de6c85265da2a
BLAKE2b-256 checksum
How to use checksums
b3201fcda4d00ac617857c0d7423b8ab203965eee1f9932a5ad5f70b8458fd46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 32.5 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
10c54d0edc5aadb9f8d826c6b7c687d63b7fa78964433206822a46dce3dfec4d
BLAKE2b-256 checksum
How to use checksums
f20d807b956c92bca6001381fc2c86ae20fa2a41d216d995f4fb7fddec4f44c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 33.7 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
8c101069ac64cbfdad8883a6ceb964b1bb3bd636f9b0dee0cf4d97a520c11398
BLAKE2b-256 checksum
How to use checksums
0acb69bb8168006fcc3ccbe9f19e9ba40e1f67aca0e74f6e67f41f639ee45f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 34.7 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
dd87b68a50ad63b4ce3f0d417b6c0dcdb2890c182565f13b56230675f1986219
BLAKE2b-256 checksum
How to use checksums
87af419058ce9cbb7f0f5cb2f5ed830f9bb66c3d0bbf04a3b972063cf5265ea5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 32.8 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
28092e8102dd223cb2a1b759569d485c9ff85bf8dae9bf9e41c6b26b9cf6a5f7
BLAKE2b-256 checksum
How to use checksums
11d54c928c0b69aeae0da1575f7f81621663fd71527be01e5f8027743b3a06d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Size 19.9 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
27395fbca17132255dae517867c8865cc53f482bdd62122563423b1387f564a6
BLAKE2b-256 checksum
How to use checksums
6633e75d51d9772af783df5bc7eb79cb1362d5cf594ef984aef2780019534f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_gram-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_gram-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl
Size 19.5 kB
Tags CPython 3.9 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
95ef6e598c4a1cee987ba7e5a5b8a5bb60d028fb6818cec975b3707d9af9d1b6
BLAKE2b-256 checksum
How to use checksums
7a2426291c409d0d5a5b7a35e43b31f396acfd55f6a3fd8729ff62afec7ece87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tree-sitter-gram 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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