Expand description
Legacy Pest-based Perl parser (v2).
This crate provides a pure Rust Perl parser built with the Pest parser generator. It outputs tree-sitter compatible S-expressions and requires no C dependencies.
Note: This is maintained as a learning tool and historical reference.
For production parsing and LSP, use perl-parser (v3).
§Example
ⓘ
use perl_parser_pest::PureRustPerlParser;
let mut parser = PureRustPerlParser::new();
let code = r#"
sub hello {
my $name = shift;
print "Hello, $name!\n";
}
"#;
let ast = parser.parse(code)?;
let sexp = parser.to_sexp(&ast);
println!("{}", sexp);§Architecture
The parser uses a three-stage pipeline:
- Pest Parsing: PEG grammar processes input into parse tree
- AST Building: Type-safe AST construction with position tracking
- S-Expression Output: Tree-sitter compatible format generation
Re-exports§
pub use error::ParseError;pub use error::ParseResult;pub use pratt_parser::PrattParser;pub use pure_rust_parser::AstNode;pub use pure_rust_parser::PerlParser;pub use pure_rust_parser::PureRustPerlParser;pub use sexp_formatter::SexpFormatter;
Modules§
- error
- Error types for tree-sitter Perl parser
- pratt_
parser - pure_
rust_ parser - Pure Rust Perl parser implementation
- sexp_
formatter - S-expression formatter for AST nodes