pub enum Error<'source> {
ProgramLimitExceeded,
InvalidBreak(Token<'source>),
InvalidInteger(Token<'source>, ParseIntError),
InvalidString(Token<'source>, EscapeError),
InvalidIdentifier(Token<'source>, EscapeError),
UndefinedSymbol(Token<'source>),
InvalidAst(Error<'source>),
}Variants§
ProgramLimitExceeded
Emitted when the program is too large (produced bytecode larger than 4GiB)
InvalidBreak(Token<'source>)
Attempted to break out of a scope, but no parent scope accepted unlabeled breaks.
InvalidInteger(Token<'source>, ParseIntError)
The AST contained an integer that did not fit into the expected type.
InvalidString(Token<'source>, EscapeError)
The AST contained a string with an invalid escape sequence.
InvalidIdentifier(Token<'source>, EscapeError)
The AST contained an identifier with an invalid escape sequence.
UndefinedSymbol(Token<'source>)
A variable was referenced that did not exist.
InvalidAst(Error<'source>)
The AST contained an error.
Note that this only contains the first error that the parser encounted. Inspecting the AST directly allows you to see all of the errors the parser encountered with some additional context.
Implementations§
Source§impl<'source> Error<'source>
impl<'source> Error<'source>
Sourcepub fn locate(&self, source: &'source str) -> Option<(usize, usize)>
pub fn locate(&self, source: &'source str) -> Option<(usize, usize)>
Provides the span of source code causing this compiler error, if one is available.
Note that this method will return None in the case of an invalid ast.
Inspect ast diagnostics directly if you want to format them.
§Panics
Panics if provided a aosurce string slice that this error did not originate from.