pub enum ParseError {
Expected {
expected: Cow<'static, str>,
found: TokenKind,
span: Span,
},
Unexpected {
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,
},
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.
Unexpected
A token appeared where it is not valid.
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).
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§
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()