implement SyntaxError attributes

This commit is contained in:
Jeong YunWon 2019-12-14 22:05:15 +09:00
parent aff1a6d53c
commit 23993c2833
3 changed files with 24 additions and 3 deletions

View file

@ -10,12 +10,18 @@ pub struct CompileError {
pub statement: Option<String>,
pub error: CompileErrorType,
pub location: Location,
pub source_path: Option<String>,
}
impl CompileError {
pub fn update_statement_info(&mut self, statement: String) {
self.statement = Some(statement);
}
pub fn update_source_path(&mut self, source_path: &str) {
debug_assert!(self.source_path.is_none());
self.source_path = Some(source_path.to_owned());
}
}
impl From<ParseError> for CompileError {
@ -24,6 +30,7 @@ impl From<ParseError> for CompileError {
statement: None,
error: CompileErrorType::Parse(error.error),
location: error.location,
source_path: None,
}
}
}