pub enum ParseError {
UnexpectedEof,
UnexpectedToken {
expected: String,
found: String,
location: usize,
},
SyntaxError {
message: String,
location: usize,
},
LexerError {
message: String,
},
RecursionLimit,
InvalidNumber {
literal: String,
},
InvalidString,
UnclosedDelimiter {
delimiter: char,
},
InvalidRegex {
message: String,
},
NestingTooDeep {
depth: usize,
max_depth: usize,
},
Cancelled,
Recovered {
site: RecoverySite,
kind: RecoveryKind,
location: usize,
},
}Expand description
Parse error and result types for parser output. Comprehensive error types that can occur during Perl parsing workflows
These errors are designed to provide detailed context about parsing failures that occur during Perl code analysis, script processing, and metadata extraction. Each error variant includes location information to enable precise recovery strategies in large Perl file processing scenarios.
§Error Recovery Patterns
- Syntax Errors: Attempt fallback parsing or skip problematic content sections
- Lexer Errors: Re-tokenize with relaxed rules or binary content detection
- Recursion Limits: Flatten deeply nested structures or process iteratively
- String Handling: Apply encoding detection and normalization workflows
§Enterprise Scale Considerations
Error handling is optimized for large Perl files and multi-file workspaces, ensuring memory-efficient error propagation and logging.
Variants§
UnexpectedEof
Parser encountered unexpected end of input during Perl code analysis
This occurs when processing truncated Perl scripts or incomplete Perl source during the Parse stage. Recovery strategy: attempt partial parsing and preserve available content.
UnexpectedToken
Parser found an unexpected token during Perl parsing workflow
Common during Analyze stage when Perl scripts contain syntax variations or encoding issues. Recovery strategy: skip problematic tokens and attempt continued parsing with relaxed rules.
Fields
SyntaxError
General syntax error occurred during Perl code parsing
This encompasses malformed Perl constructs found in Perl scripts during Navigate stage analysis. Recovery strategy: isolate syntax error scope and continue processing surrounding content.
Fields
LexerError
Lexical analysis failure during Perl script tokenization
Indicates character encoding issues or binary content mixed with text during Parse stage. Recovery strategy: apply encoding detection and re-attempt tokenization with binary fallbacks.
RecursionLimit
Parser recursion depth exceeded during complex Perl script analysis
Occurs with deeply nested structures in Perl code during Complete stage processing. Recovery strategy: flatten recursive structures and process iteratively to maintain performance.
InvalidNumber
Invalid numeric literal found in Perl script content
Common when processing malformed configuration values during Analyze stage analysis. Recovery strategy: substitute default values and log for manual review.
InvalidString
Malformed string literal in Perl parsing workflow
Indicates quote mismatches or encoding issues in Perl script strings during parsing. Recovery strategy: attempt string repair and normalization before re-parsing.
UnclosedDelimiter
Unclosed delimiter detected during Perl code parsing
Commonly found in truncated or corrupted Perl script content during Parse stage. Recovery strategy: auto-close delimiters and continue parsing with synthetic boundaries.
InvalidRegex
Invalid regular expression syntax in Perl parsing workflow
Occurs when parsing regex patterns in data filters during Navigate stage analysis. Recovery strategy: fallback to literal string matching and preserve original pattern.
NestingTooDeep
Nesting depth limit exceeded for recursive structures
Cancelled
Parsing was cancelled by an external cancellation token
Recovered
A syntax error was recovered from — parsing continued with a synthetic node.
This variant is emitted alongside the partial AST node that was produced
by the recovery. LSP providers iterate parser.errors() and count
Recovered variants to determine confidence for gating features.
Fields
site: RecoverySiteWhere in the parse tree the recovery occurred.
kind: RecoveryKindWhat kind of repair was applied.
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub fn syntax(message: impl Into<String>, location: usize) -> ParseError
pub fn syntax(message: impl Into<String>, location: usize) -> ParseError
Create a new syntax error for Perl parsing workflow failures
§Arguments
message- Descriptive error message with context about the syntax issuelocation- Character position within the Perl code where error occurred
§Returns
A ParseError::SyntaxError variant with embedded location context for recovery strategies
§Examples
use perl_error::ParseError;
let error = ParseError::syntax("Missing semicolon in Perl script", 42);
assert!(matches!(error, ParseError::SyntaxError { .. }));Sourcepub fn unexpected(
expected: impl Into<String>,
found: impl Into<String>,
location: usize,
) -> ParseError
pub fn unexpected( expected: impl Into<String>, found: impl Into<String>, location: usize, ) -> ParseError
Create a new unexpected token error during Perl script parsing
§Arguments
expected- Token type that was expected by the parserfound- Actual token type that was encounteredlocation- Character position where the unexpected token was found
§Returns
A ParseError::UnexpectedToken variant with detailed token mismatch information
§Examples
use perl_error::ParseError;
let error = ParseError::unexpected("semicolon", "comma", 15);
assert!(matches!(error, ParseError::UnexpectedToken { .. }));§Email Processing Context
This is commonly used during the Analyze stage when Perl scripts contain syntax variations that require token-level recovery strategies.
Sourcepub fn suggestion(&self) -> Option<String>
pub fn suggestion(&self) -> Option<String>
Generate a fix suggestion based on the error type
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()