mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-22 20:45:28 +00:00
implement SyntaxError attributes
This commit is contained in:
parent
aff1a6d53c
commit
23993c2833
3 changed files with 24 additions and 3 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue