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

Built distributions (wheels)

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

Total release size: 234.3 kB

Release files / tree_sitter_gram-0.6.0.tar.gz

Download URL tree_sitter_gram-0.6.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b2f9b331fd1f193ee49f5154868ec6075fe017813213015efa80542567a7af70
BLAKE2b-256 checksum
How to use checksums
7a45b734c0b3e284406bf209818160d9d77cbdf1418635698267e2781239b00f
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.0-cp39-abi3-win_arm64.whl

Download URL tree_sitter_gram-0.6.0-cp39-abi3-win_arm64.whl
Size 20.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
c02f1815b650062242b1af8cf740b33b9bd586a96e44fef993c7de5aa04b7e36
BLAKE2b-256 checksum
How to use checksums
b21d5a48b73af12fc60bb05ae4e60503208bb075b247d7e0791b705651ece083
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.0-cp39-abi3-win_amd64.whl

Download URL tree_sitter_gram-0.6.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
32c052b900ab70c82886a47dfe7ad6b02e3fb86147b86c6645a09bc156cdcf4d
BLAKE2b-256 checksum
How to use checksums
63d3751230fb203d9d978b22e93cc764507795f791967ffb8e1fb2ea045cc7f3
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.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_gram-0.6.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
7b84cce42a6d418fb8c27d23a661de08429085080b1dd925980c3041a5657b91
BLAKE2b-256 checksum
How to use checksums
44d3a90f176c79135e8027846a732c46dd365b99d42d668c44dbd17a24e26c45
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.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_gram-0.6.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
4257b6219fd1d5faab6a25f611dc8c3807832f9c922f3d7910bfcafced445237
BLAKE2b-256 checksum
How to use checksums
0c69f73c6311f9ce44c347d4f887ac1a7e6f0fc8e68d3a3283911b0f81be7da2
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.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_gram-0.6.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
c5459d54df942900fb8c22e1d4a984429b2c1bc9d222b41c609714874a821168
BLAKE2b-256 checksum
How to use checksums
c9f6c178161f0ebc5dce6558ccccc7726d0af0c58b97911e427958843be6bc26
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.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_gram-0.6.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
e5cfeadfa7fa8339e0895e76f0e6c2bacf6b57e9ccc49770540dbd6d561440e2
BLAKE2b-256 checksum
How to use checksums
be57473dadcaed6b2f76ba571687fa62bf25531c37a30a838052242da743056a
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.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_gram-0.6.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
3408241d25195aa2f69b5885344b4ffa12365b546e26d67e958cedb17a6a5dd3
BLAKE2b-256 checksum
How to use checksums
c85c1f6d8544e07c5aa18de642b582f26c464ab405d7eb2aff6bbcb96060d970
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.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_gram-0.6.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
c0564ecddf8889c97b5882212965cca34fe00b5aa650f54819af1aa882b7a328
BLAKE2b-256 checksum
How to use checksums
c5df8a8d6ac4aeb5885f84fd01bb898698d95a2788be00e5d0d820b76642539e
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.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