pub enum ParseError {
Expected {
expected: Cow<'static, str>,
found: TokenKind,
span: Span,
},
ExpectedExpression {
span: Span,
},
ExpectedStatement {
span: Span,
},
ExpectedOpenTag {
span: Span,
},
UnterminatedString {
span: Span,
},
ExpectedAfter {
expected: Cow<'static, str>,
after: Cow<'static, str>,
span: Span,
},
UnclosedDelimiter {
delimiter: Cow<'static, str>,
opened_at: Span,
span: Span,
},
Forbidden {
message: Cow<'static, str>,
span: Span,
},
ForbiddenWarning {
message: Cow<'static, str>,
span: Span,
},
VersionTooLow {
feature: Cow<'static, str>,
required: Cow<'static, str>,
used: Cow<'static, str>,
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§
Expected
A specific token was expected but a different one was found.
ExpectedExpression
An expression was expected but not found (e.g. empty parentheses).
ExpectedStatement
A statement was expected but not found.
ExpectedOpenTag
PHP source must start with <?php or <?.
UnterminatedString
A string literal was opened but never closed.
ExpectedAfter
A required token was missing after another construct.
UnclosedDelimiter
A delimiter (parenthesis, bracket, brace) was opened but never closed.
Forbidden
A construct that is syntactically valid but semantically forbidden
(e.g. (unset) cast, deprecated syntax). Equivalent to a PHP fatal.
ForbiddenWarning
A construct PHP only warns about (e.g. final private method). Treated
as a non-fatal diagnostic; severity() returns Severity::Warning.
VersionTooLow
Syntax that requires a newer PHP version than the targeted one.
Emitted by crate::parse_versioned when the source uses features
unavailable in the specified crate::PhpVersion.
Implementations§
Source§impl ParseError
impl ParseError
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()