Expand description
Core parser engine for Perl source code.
perl-parser-core is the foundational crate that wires together the lexer,
AST, error recovery, and position mapping into a single Parser entry
point. Higher-level crates – semantic analysis, workspace indexing, and the
LSP server – all build on top of this crate.
§Key types
| Type | Role |
|---|---|
Parser | Recursive-descent parser; call Parser::parse to get an AST |
Node / NodeKind | AST node and its discriminant (re-exported from perl-ast) |
ParseError | Syntax error collected during parsing |
ParseOutput | AST + diagnostics bundle for IDE workflows |
Token / TokenKind | Lexer tokens consumed by the parser |
SourceLocation | Byte-offset span for every node |
§Quick start
use perl_parser_core::{Parser, Node, NodeKind};
let mut parser = Parser::new("my $x = 42;");
let ast = parser.parse().expect("should parse");
// The root is always a Program node
assert!(matches!(ast.kind, NodeKind::Program { .. }));
// Non-fatal errors are collected, not returned as Err
assert!(parser.errors().is_empty());For IDE workflows that need error-tolerant parsing, use
Parser::parse_with_recovery:
use perl_parser_core::Parser;
let mut parser = Parser::new("if (");
let output = parser.parse_with_recovery();
// Always returns an AST (possibly with ERROR nodes)
assert!(!output.diagnostics.is_empty());Re-exports§
pub use engine::ast;pub use engine::parser_context;pub use engine::quote_parser;pub use engine::error;pub use engine::parser;pub use engine::position;pub use syntax::edit;pub use syntax::heredoc as heredoc_collector;pub use syntax::path_normalize;pub use syntax::path_security;pub use syntax::percentile;pub use syntax::qualified_name;pub use syntax::source_file;pub use syntax::text_line;pub use engine::parser::Parser;pub use error::classifier as error_classifier;pub use error::recovery as error_recovery;pub use error_recovery::RecoveryResult;pub use error::classifier::RecoverySalvageMetrics;pub use error::classifier::classify_recovery_salvage;pub use error::BudgetTracker;pub use error::ParseBudget;pub use error::ParseError;pub use error::ParseOutput;pub use error::ParseResult;pub use error::RecoverySalvageClass;pub use error::RecoverySalvageProfile;pub use tokens::token_stream;pub use tokens::trivia;pub use tokens::trivia_parser;pub use token_stream::TokenStream;pub use trivia::NodeWithTrivia;pub use trivia::Trivia;pub use trivia::TriviaToken;pub use trivia_parser::TriviaPreservingParser;pub use trivia_parser::format_with_trivia;pub use engine::ast_v2;pub use engine::pragma_tracker;
Modules§
- builtin_
signatures - Builtin function signature lookup tables. Comprehensive built-in function signatures for Perl scripting.
- builtin_
signatures_ phf - Perfect hash function (PHF) based builtin signature lookup. Consolidated built-in function signatures for Perl using perfect hash
- builtins
- Builtin function signatures and metadata. Builtin function signatures and metadata for Perl.
- engine
- Parser engine components and supporting utilities. Parser engine components and supporting utilities.
- line_
index - Line indexing and position mapping utilities.
- syntax
- Syntax-level types absorbed from Wave D satellite crates. Syntax-level types and utilities absorbed from Wave D satellite crates.
- token_
wrapper - Lightweight token wrapper for AST integration. Token wrapper utilities for preserving original lexemes. Token wrapper with enhanced position tracking
- tokens
- Token stream and trivia utilities for the parser. Token stream and trivia utilities for parser workflows.
- util
- Parser utilities and helpers. Tokenization utilities shared by parser-facing entry points.
Structs§
- Node
- Core AST types re-exported for convenience. Re-exported AST node types used during Parse/Index/Analyze stages. Core AST node representing any Perl language construct within parsing workflows.
- Position
Mapper - Line ending detection for mixed-EOL source files. Centralized position mapper using rope for efficiency.
- Token
- Individual token, its classification, and the streaming iterator. Token produced by the lexer and consumed by the parser.
Enums§
- Line
Ending - Line ending detection for mixed-EOL source files. Line ending style detected in a document
- Missing
Kind - Index into the diagnostics array in
ParseOutput(fromast_v2). Kinds of missing syntax elements for error recovery. - Node
Kind - Core AST types re-exported for convenience. Re-exported AST node types used during Parse/Index/Analyze stages. Comprehensive enumeration of all Perl language constructs supported by the parser.
- Token
Kind - Individual token, its classification, and the streaming iterator. Token classification for Perl parsing.
Type Aliases§
- Diagnostic
Id - Index into the diagnostics array in
ParseOutput(fromast_v2). Index into the diagnostics array inParseOutput. - Source
Location - Core AST types re-exported for convenience.
Re-exported AST node types used during Parse/Index/Analyze stages.
Type alias for backward compatibility with
SourceLocation.