Implement TabError

This commit is contained in:
Seo Sanghyeon 2019-10-05 09:19:33 +09:00
parent fe4f8237ad
commit a1e228d4ee

View file

@ -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 {