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

Built distributions (wheels)

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

Total release size: 234.1 kB

Release files / tree_sitter_gram-0.7.0.tar.gz

Download URL tree_sitter_gram-0.7.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2da82cb34775d37182458fa6c713e8e94f25030bb8fd7f3dedb8fbbab919d995
BLAKE2b-256 checksum
How to use checksums
05cf62039535e0bab345488bcdb47a0e664ab2287d32554186e9706777d1d5e6
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.7.0-cp39-abi3-win_arm64.whl

Download URL tree_sitter_gram-0.7.0-cp39-abi3-win_arm64.whl
Size 20.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
e23c94ddcaa0dde761625c09afcdc3a0dd310410e7e7781fe07e844fb9677752
BLAKE2b-256 checksum
How to use checksums
2a6f232e263a5ae700eee670cbf0a4c952d2f7d3e2be5ec8b5d096f61d45525a
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.7.0-cp39-abi3-win_amd64.whl

Download URL tree_sitter_gram-0.7.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
fa6ec5f5befa51ce336548da747ae0349a4cbfd89d3bec5c932e0160d1591372
BLAKE2b-256 checksum
How to use checksums
705f7d94d975cbd3f5cb7fd97346e0f2a10d3d5c44875091feccce3098ec49f3
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.7.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_gram-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 32.4 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
22c426911b5d5d1a3d6ffecbc64d9cfc532610c05ad54d17a4f6b7f29019c193
BLAKE2b-256 checksum
How to use checksums
c02609ff299624b3227a6368930ba4d9c786501472d8800e7f646a0af4f93864
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.7.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_gram-0.7.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
cb060968c19da7d36c4b4fd6fcaa46e223c54817bad466cf9ea79cd0823ac7d5
BLAKE2b-256 checksum
How to use checksums
f572abab5b145a6965ae3c363985562b05807cffb9c3e81328ceab3d0de31345
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.7.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_gram-0.7.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
839db1dcb1c9efecf4524fdbb97a2459c2e9166ba74e4c658cac0402a7e40d40
BLAKE2b-256 checksum
How to use checksums
49313903d1a7e7820209f5b12ade8137c5d4c0f7dfa5bc60d5f447cecbe935dd
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.7.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_gram-0.7.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
28a6bf4b9c96463a301588679f9fde03e5b19adaa72dd73eeffe29a6d15a2b6e
BLAKE2b-256 checksum
How to use checksums
00487691b279c0de5abae348aa27093aefecdce80c6682c7241806a511010540
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.7.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_gram-0.7.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
2b42c000adc5b28925360f4fbad958962726401173cce7485cd1bc88af4f4ca0
BLAKE2b-256 checksum
How to use checksums
9552cdf91264d6734156822849b126b531a5dec8898a6ab6854aed107c430268
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.7.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_gram-0.7.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
12b9aa7164adb57b9cb2cd24b9b00908b90499a94bfdfd99649af51b189a8cdb
BLAKE2b-256 checksum
How to use checksums
77922a3e33ae1cba98d4982284d699419492a8498c99e1fd40f697cc803207b0
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.7.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