pub enum ParserError {
SyntaxError,
TooManyErrors,
Irrecoverable,
ExtraSymbol,
UnexpectedEOS,
UnexpectedError,
EncounteredErrors,
AbortRequest,
}Expand description
Code of the error that occurred during the parsing, returned by the parse_stream(…) method of the parser.
Variants§
SyntaxError
A syntax error was met. Either
- The next terminal of the parsed text doesn’t match the expected one in the current rule
alternative; for example, a rule
assign -> "let" Id "=" expr ";";has just successfully scanned the terminal"let", but the next one isn’tId. - The next symbol doesn’t correspond to any correct option for the next nonterminal (
in other words, there is no entry in the parsing table for that combination). For example,
in the same rule as above, the terminal
"="has just been scanned successfully, butexprdoesn’t begin with the next one.
This error is returned only when the parser doesn’t try to recover from syntax errors; this option is set with the set_try_recover(…) method and is enabled by default.
See also ParserError::TooManyErrors.
TooManyErrors
Too many syntax errors were met, either
- during the parsing. The limit is set by the constant Parser::MAX_NBR_RECOVERS.
- by the lexer. The limit is set by the constant Parser::MAX_NBR_LEXER_ERRORS.
This error is returned only when the parser tries to recover from syntactic or lexical errors; this option is set with the set_try_recover(…) method and is enabled by default.
See also ParserError::SyntaxError.
Irrecoverable
The parser has reached an irrecoverable error, after trying to recover from a syntax error and encountering the end of the text.
ExtraSymbol
The parser has reached the end of the top rule, but there are still terminals coming from the lexer.
Note that if the text is expected to contain something else after the part that must be parsed, it is possible to tell the parser to conclude the parsing without looking any further. This can be done in the listener with the [check_abort_request(…)] performed regularly by the parser. See the [examples/terminate] parser to see how it can be used.
UnexpectedEOS
The parser has encountered the end of the text, but the top rule hasn’t been fully parsed.
UnexpectedError
This is an internal error that isn’t supposed to happen.
EncounteredErrors
The text has been fully parsed, but syntax errors were encountered by the parser (and could be recovered from).
See also ParserError::SyntaxError.
AbortRequest
An Abort was returned by the [check_abort_request(…)] method of the listener.
Trait Implementations§
Source§impl Debug for ParserError
impl Debug for ParserError
Source§impl Display for ParserError
impl Display for ParserError
Source§impl PartialEq for ParserError
impl PartialEq for ParserError
impl StructuralPartialEq for ParserError
Auto Trait Implementations§
impl Freeze for ParserError
impl RefUnwindSafe for ParserError
impl Send for ParserError
impl Sync for ParserError
impl Unpin for ParserError
impl UnsafeUnpin for ParserError
impl UnwindSafe for ParserError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> BuildFrom<S> for S
impl<S> BuildFrom<S> for S
Source§fn build_from(source: S) -> S
fn build_from(source: S) -> S
Source§impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
Source§fn build_into(self) -> T
fn build_into(self) -> T
Calls T::from(self) to convert a S into a T.