gremlin-rs 0.1.0

Parser for the Gremlin graph traversal language, generated from Apache TinkerPop's official Gremlin.g4 grammar.
Documentation
  • Coverage
  • 75%
    6 out of 8 items documented1 out of 4 items with examples
  • Size
  • Source code size: 2.13 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.47 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ophi-dev/gremlin-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tinovyatkin

gremlin-rs

A Rust parser for the Gremlin graph traversal language, generated from Apache TinkerPop™'s official Gremlin.g4 grammar via antlr-rust-runtime.

use gremlin_rs::parse;

let tree = parse("g.V().has('name','marko').out('knows').values('name')")?;
println!("{}", tree.text());
# Ok::<(), gremlin_rs::GremlinParseError>(())

Parser, not a client

This crate parses Gremlin text into a parse tree. It is not a database client and does not talk to a Gremlin Server — for that, see gremlin-client. Use gremlin-rs when you need to read, analyze, translate, lint, or transform Gremlin source:

  • tooling (formatters, linters, syntax highlighting, LSPs)
  • query translation / rewriting
  • static analysis of stored or user-submitted traversals

Why generated from the official grammar

TinkerPop maintains one grammar, Gremlin.g4, and generates its JVM and JavaScript language variants' text parsers from it. gremlin-rs is generated from that same grammar, so it tracks the official language definition rather than a hand-maintained re-implementation that can drift as Gremlin evolves.

API

  • [parse] — parse a ;-separated query list (grammar entry rule queryList).
  • [parse_query] — parse a single traversal/expression (entry rule query).

Both return [ParseTree] on success. Invalid input returns a GremlinParseErrorSyntax { count, tree } when the parser recovered from syntax errors (the best-effort tree is still provided), or Runtime on an unrecoverable error.

Provenance

Grammar apache/tinkerpop gremlin-language/src/main/antlr4/Gremlin.g4
Grammar commit 5dcf41fe6161 (2026-07-09)
Runtime antlr-rust-runtime 0.9
Generated with antlr4-rust-gen (from the ANTLR .interp metadata)

The generated lexer/parser modules under src/generated/ are committed so the crate builds without ANTLR or a JVM. To regenerate against a newer Gremlin.g4, see grammar/REGENERATE.md.

License

Licensed under the Apache License, Version 2.0. The Gremlin.g4 grammar this parser is generated from is © the Apache Software Foundation, licensed under Apache-2.0; see NOTICE. "Gremlin", "TinkerPop", and "Apache TinkerPop" are trademarks of the Apache Software Foundation. This is an independent project and is not affiliated with or endorsed by the ASF.