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

Built distributions (wheels)

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

Total release size: 234.2 kB

Release files / tree_sitter_gram-0.4.0.tar.gz

Download URL tree_sitter_gram-0.4.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d5504d3ce2c6283375c52ee244bb2889d95c54eb2e25ba454cda844881b8ae30
BLAKE2b-256 checksum
How to use checksums
fb6ac4b4dcd3eadbca4d2e72cddc02a45811ef289d6a4eec0606ec0b71a00384
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.4.0-cp39-abi3-win_arm64.whl

Download URL tree_sitter_gram-0.4.0-cp39-abi3-win_arm64.whl
Size 20.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6eaefe6248f85ff4aeb1b67536e3029f2d2e2d62fa3d02c542d590db1517eb32
BLAKE2b-256 checksum
How to use checksums
d0ef93888606e1cc6498eba93ae8e4c60c29e7d2f4a780557e4a31e9ef89ad1e
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.4.0-cp39-abi3-win_amd64.whl

Download URL tree_sitter_gram-0.4.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
1285b21ea9821c65ee69bcd618636a26662e22c10faa978ef5353434158c5fbe
BLAKE2b-256 checksum
How to use checksums
206e630ce755487cc1148540a1539d7fc9544e710ab4ca5ffa1ae71dbf9ef334
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.4.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_gram-0.4.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
d7162451babd09f1d2323f576a7550b3687ef035cb0e5465aefc5ddfde0980a0
BLAKE2b-256 checksum
How to use checksums
0834eb20123a74bc0c6c8650c1c927edcd650bc3f2b5cc6b83c5741cb2d0bd41
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.4.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_gram-0.4.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
dd1c0644a645ee86ee55261a15239bb86da18af416e27b0ffefad43ff263d7ff
BLAKE2b-256 checksum
How to use checksums
21c7a3a9641f2e698f7e8e9840bcf3838392c1bcf9f79aa9bc911dc6ae90c887
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.4.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_gram-0.4.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
8c4ac3e5582b715a3ec2263129eb40a340b64fee45a6e3cf1d8072aafc4b39d4
BLAKE2b-256 checksum
How to use checksums
22b9a364a44d9eaa8db3032d6f15c919f73d85f97410efe1830d955b3d36b486
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.4.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_gram-0.4.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
824c48e775f5cd9de61aa477a2921657a2d79e9c57a804df68d3187767f6328a
BLAKE2b-256 checksum
How to use checksums
beb6f7bf38896b0cda8d19c27654c413bb273bd6b93a4b05e551e7cc87529745
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.4.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_gram-0.4.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
e5be63f2fb4b393f48748d74c263c385b826eb0b3bf043575c85bc31cf1bebbb
BLAKE2b-256 checksum
How to use checksums
909ac099ebf0e4f7e7d5a4d77c51890dac98c2e024d18b64eb3a6311a8a26c2a
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.4.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_gram-0.4.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
404a89bd0b56154e92fe95ea0d6ca33d433802cbda8f91ca6dddc36264f4e2b4
BLAKE2b-256 checksum
How to use checksums
61f60d13e8ed7121c7346caa216e0427b8d18eb4423ad56fd5e77a32dcfa0f6f
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.4.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