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.6.1

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

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-gram 0.6.1
File Actions
tree_sitter_gram-0.6.1-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for tree_sitter_gram-0.6.1-cp39-abi3-win_arm64.whl
tree_sitter_gram-0.6.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for tree_sitter_gram-0.6.1-cp39-abi3-win_amd64.whl
tree_sitter_gram-0.6.1-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_gram-0.6.1-cp39-abi3-musllinux_1_2_x86_64.whl
tree_sitter_gram-0.6.1-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_gram-0.6.1-cp39-abi3-musllinux_1_2_aarch64.whl
tree_sitter_gram-0.6.1-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.6.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_gram-0.6.1-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.6.1-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_gram-0.6.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for tree_sitter_gram-0.6.1-cp39-abi3-macosx_11_0_arm64.whl
tree_sitter_gram-0.6.1-cp39-abi3-macosx_10_9_x86_64.whl CPython 3.9 abi3 macOS 10.9+ x86-64 Details for tree_sitter_gram-0.6.1-cp39-abi3-macosx_10_9_x86_64.whl

Total release size: 234.3 kB

Release files / tree_sitter_gram-0.6.1.tar.gz

Download URL tree_sitter_gram-0.6.1.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5b9dd8cfe24e5f08e76ae77a37f2ea7ab89dc82fc83f6ca66ccf6be7dff28121
BLAKE2b-256 checksum
How to use checksums
1bf04fe3d2cc05ab370ba029248711c937ba007360ed8345e979a992d72f1262
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.6.1-cp39-abi3-win_arm64.whl

Download URL tree_sitter_gram-0.6.1-cp39-abi3-win_arm64.whl
Size 20.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
3630c6f11f7ce2d727660debca9780b57e73e78a134dfd0cc45779df4bdac6c0
BLAKE2b-256 checksum
How to use checksums
a90114357d6c4069dde61fa7eb99e5e26c5428582eb485ee6a3011fa13cf6169
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.6.1-cp39-abi3-win_amd64.whl

Download URL tree_sitter_gram-0.6.1-cp39-abi3-win_amd64.whl
Size 20.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
537374f4f8beda50e01533e67f22c817fb59f00c10ba6ee9d96b9d0172ffb54f
BLAKE2b-256 checksum
How to use checksums
6e7e2c6846eee877f029d50760dcfc6108f425ff9aee16747edc099ad73b749f
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.6.1-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_gram-0.6.1-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
ad0aef49a6c6205776c472963228d0ad8a104e5949fe091f9a8c9e9a28df484c
BLAKE2b-256 checksum
How to use checksums
8f4f180b6dc497b80b8dc62d0092ad7ef820de08408fb562f02c24c60cd9e8bd
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.6.1-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_gram-0.6.1-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
060287fbf508b6b876e4fc15a4ae2236be2b7fee52d4bbe66cb90c6f877969da
BLAKE2b-256 checksum
How to use checksums
7ae696f8c4dc091fe9c7f5a9b7fd0ba88fe8a7c61baa1c627269268495e42ef3
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.6.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_gram-0.6.1-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
e8318788ecd991bedf77d640af46321678ad574b9e67bc17ed5366bdc55e0586
BLAKE2b-256 checksum
How to use checksums
3e4b6d80346590408d237da2c10340822b251c713a25fa1d3d0f406e5c8a80e3
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.6.1-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_gram-0.6.1-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
fe6e36b46deb8e11b20c62764abfcc8b64e923b16c01b7baeed5a6275c0b8576
BLAKE2b-256 checksum
How to use checksums
710e4f818273ea4ff4de7ee81bf6e7318e15fdabffd353df4396755b0c93e917
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.6.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_gram-0.6.1-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
d39ccd9ca6ef9d3614ff4b7932d631b49cbb275e889f4e245d16075c0f099842
BLAKE2b-256 checksum
How to use checksums
c486d4e6ada95e74b09e42401263f04cd6d66337fbbb6b9932e60ba4c83b31af
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.6.1-cp39-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_gram-0.6.1-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
197744f0ec84f3e0bca9c2a514fd5d86e68963929801a3463c045abfb756946f
BLAKE2b-256 checksum
How to use checksums
5e321607d8ca9d14b9648ede4f0437358379377045a1215f6fd0cdb96c24f0dd
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.6.1

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