mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-15 17:15:24 +00:00
Implement TabError
This commit is contained in:
parent
fe4f8237ad
commit
a1e228d4ee
1 changed files with 14 additions and 1 deletions
15
src/error.rs
15
src/error.rs
|
@ -1,4 +1,4 @@
|
|||
use rustpython_parser::error::{ParseError, ParseErrorType};
|
||||
use rustpython_parser::error::{LexicalErrorType, ParseError, ParseErrorType};
|
||||
use rustpython_parser::location::Location;
|
||||
|
||||
use std::error::Error;
|
||||
|
@ -40,6 +40,19 @@ pub enum CompileErrorType {
|
|||
InvalidYield,
|
||||
}
|
||||
|
||||
impl CompileError {
|
||||
pub fn is_tab_error(&self) -> bool {
|
||||
if let CompileErrorType::Parse(parse) = &self.error {
|
||||
if let ParseErrorType::Lexical(lex) = parse {
|
||||
if let LexicalErrorType::TabError = lex {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for CompileError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match &self.error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue