From a1e228d4eed357e882b2508d2dc13806a74c16ff Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Sat, 5 Oct 2019 09:19:33 +0900 Subject: [PATCH] Implement TabError --- src/error.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 {