#[non_exhaustive]pub enum ParseError {
#[non_exhaustive] Expected {
expected: Cow<'static, str>,
found: Cow<'static, str>,
span: Span,
},
#[non_exhaustive] ExpectedExpression {
span: Span,
},
#[non_exhaustive] ExpectedStatement {
span: Span,
},
#[non_exhaustive] ExpectedOpenTag {
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] Forbidden {
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]ExpectedExpression
An expression was expected but not found (e.g. empty parentheses).
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]ExpectedStatement
A statement was expected but not found.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]ExpectedOpenTag
PHP source must start with <?php or <?.
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]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
#[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§
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()