Skip to main content

Crate perl_parser_pest

Crate perl_parser_pest 

Source
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:

  1. Pest Parsing: PEG grammar processes input into parse tree
  2. AST Building: Type-safe AST construction with position tracking
  3. 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