Skip to main content

Crate tree_sitter_perl_rs

Crate tree_sitter_perl_rs 

Source
Expand description

Rust-native Perl parser with tree-sitter-style ergonomics and tree-sitter-compatible output. This is a facade over the v3 native parser (perl-parser-core); it is NOT bindings to the C tree-sitter grammar. For the conventional tree-sitter binding, see tree-sitter-perl-c.

§Quick start

use tree_sitter_perl_rs::Parser;

let mut parser = Parser::new();
if let Some(tree) = parser.parse("my $x = 42;") {
    let root = tree.root_node();
    println!("{}", root.to_sexp());
}

§Design

This crate wraps the v3 recursive-descent Perl parser (perl-parser-core) with an API surface that matches the conventions of the tree-sitter crate. Users familiar with tree-sitter can work with Perl ASTs immediately, while the underlying engine is the full-featured native v3 stack (not the C tree-sitter grammar).

Key properties:

  • Parser::parse() returns Option<Tree>None only on complete parse failure. The v3 parser is highly error-tolerant and almost always produces a partial tree.
  • Node::to_sexp() delegates to perl_ast::Node::to_sexp() for tree-sitter-compatible S-expression output.
  • Node::kind() returns the tree-sitter grammar-canonical kind string.
  • Node::start_byte() / Node::end_byte() expose the SourceLocation byte offsets.
  • Node::children() and Node::child() mirror tree-sitter traversal conventions.

§Relationship to tree-sitter-perl-c

CrateBacking engineUse when
tree-sitter-perl-rsv3 native Rust parser (this crate)You want the full-featured Rust toolchain
tree-sitter-perl-cC tree-sitter grammarYou need compatibility with the tree-sitter C ecosystem

Structs§

InputEdit
Re-export of Edit type for tree-sitter-compatible incremental parsing.
Node
A borrowed reference to a node in the syntax tree.
OverlayDefinition
Symbol definition returned by SemanticOverlay queries.
Parser
A Perl parser with tree-sitter-style ergonomics.
PerlLanguage
A descriptor for the Perl language as parsed by the native v3 engine.
Point
A tree-sitter-compatible source position.
SemanticOverlay
Experimental semantic overlay query handle.
Tree
The result of a successful parse: an owned syntax tree and the source text.
TreeCursor
Stateful cursor for navigating a subtree.
VisibleImport
Import statement visible at a specific source offset.

Enums§

PerlNodeKind
Re-export of perl_ast::NodeKind so callers can pattern-match node variants without a direct dependency on perl-ast. Comprehensive enumeration of all Perl language constructs supported by the parser.

Statics§

LANGUAGE
The PerlLanguage descriptor as a constant.

Functions§

language
Returns the PerlLanguage descriptor for Rust-native tooling.