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()returnsOption<Tree>—Noneonly on complete parse failure. The v3 parser is highly error-tolerant and almost always produces a partial tree.Node::to_sexp()delegates toperl_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 theSourceLocationbyte offsets.Node::children()andNode::child()mirror tree-sitter traversal conventions.
§Relationship to tree-sitter-perl-c
| Crate | Backing engine | Use when |
|---|---|---|
tree-sitter-perl-rs | v3 native Rust parser (this crate) | You want the full-featured Rust toolchain |
tree-sitter-perl-c | C tree-sitter grammar | You need compatibility with the tree-sitter C ecosystem |
Structs§
- Input
Edit - Re-export of Edit type for tree-sitter-compatible incremental parsing.
- Node
- A borrowed reference to a node in the syntax tree.
- Overlay
Definition - Symbol definition returned by
SemanticOverlayqueries. - Parser
- A Perl parser with tree-sitter-style ergonomics.
- Perl
Language - A descriptor for the Perl language as parsed by the native v3 engine.
- Point
- A tree-sitter-compatible source position.
- Semantic
Overlay - Experimental semantic overlay query handle.
- Tree
- The result of a successful parse: an owned syntax tree and the source text.
- Tree
Cursor - Stateful cursor for navigating a subtree.
- Visible
Import - Import statement visible at a specific source offset.
Enums§
- Perl
Node Kind - Re-export of
perl_ast::NodeKindso callers can pattern-match node variants without a direct dependency onperl-ast. Comprehensive enumeration of all Perl language constructs supported by the parser.
Statics§
- LANGUAGE
- The
PerlLanguagedescriptor as a constant.
Functions§
- language
- Returns the
PerlLanguagedescriptor for Rust-native tooling.