#[non_exhaustive]pub enum ParseError {
#[non_exhaustive] Expected {
expected: Cow<'static, str>,
found: Cow<'static, str>,
span: Span,
},
#[non_exhaustive] UnterminatedString {
span: Span,
},
#[non_exhaustive] ExpectedAfter {
expected: Cow<'static, str>,
after: Cow<'static, str>,
span: Span,
},
#[non_exhaustive] UnclosedDelimiter {
delimiter: Cow<'static, str>,
opened_at: Span,
span: Span,
},
#[non_exhaustive] UnmatchedDelimiter {
delimiter: Cow<'static, str>,
span: Span,
},
#[non_exhaustive] Forbidden {
rule: ForbiddenRule,
message: Cow<'static, str>,
span: Span,
},
#[non_exhaustive] NestingTooDeep {
span: Span,
},
#[non_exhaustive] SourceTooLarge {
len: usize,
span: Span,
},
#[non_exhaustive] VersionTooLow {
feature: Cow<'static, str>,
required: PhpVersion,
used: PhpVersion,
span: Span,
},
}Expand description
A parse error or diagnostic emitted during parsing.
The parser recovers from all errors and always produces a complete AST,
so errors are informational rather than fatal. Each variant carries a
Span identifying the source location.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]Expected
A specific token was expected but a different one was found.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]UnterminatedString
A string literal was opened but never closed.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]ExpectedAfter
A required token was missing after another construct.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]UnclosedDelimiter
A delimiter (parenthesis, bracket, brace) was opened but never closed.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]UnmatchedDelimiter
A closing delimiter with no delimiter open, such as a } after the last block.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Forbidden
A construct that is syntactically valid but semantically forbidden
(e.g. (unset) cast, deprecated syntax). Equivalent to a PHP fatal.
Fields
This variant is marked as non-exhaustive
rule: ForbiddenRuleRule violated.
#[non_exhaustive]NestingTooDeep
Statements, expressions or string interpolations are nested deeper than the parser’s recursion budget. The innermost construct is replaced by an error node so that parsing stays within a bounded stack.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]SourceTooLarge
The source is larger than 4 GiB, so byte offsets no longer fit in a
Span. Nothing is parsed and the program is empty.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]VersionTooLow
Syntax that requires a newer PHP version than the targeted one.
Emitted by crate::parse_with when the source uses features
unavailable in the specified crate::PhpVersion.
Fields
This variant is marked as non-exhaustive
required: PhpVersionMinimum PHP version required.
used: PhpVersionPHP version targeted.
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub fn forbidden_rule(&self) -> Option<ForbiddenRule>
pub fn forbidden_rule(&self) -> Option<ForbiddenRule>
Rule violated, for ParseError::Forbidden.
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
Stable kebab-case identifier: the variant’s, or the rule’s for ParseError::Forbidden.
Sourcepub fn leaves_ast_incomplete(&self) -> bool
pub fn leaves_ast_incomplete(&self) -> bool
Whether the AST around the error is a recovery guess rather than what the source says.
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§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()