diff --git a/src/error.rs b/src/error.rs index 679a914..62546dd 100644 --- a/src/error.rs +++ b/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 {