-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::parser::ParserError; | ||
|
||
pub struct ParserErrorChain(Vec<(u32, ParserError)>); | ||
|
||
impl ParserErrorChain { | ||
pub fn new() -> Self { | ||
Self(Vec::new()) | ||
} | ||
|
||
pub fn add(&mut self, (line, err): (u32, ParserError)) { | ||
self.0.push((line, err)) | ||
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.0.is_empty() | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for ParserErrorChain { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
let mut output: String = "".to_string(); | ||
for (line, err) in &self.0 { | ||
output.push_str(&format!( | ||
"At line {} found error: {}\n", | ||
line.to_string(), | ||
err | ||
)); | ||
} | ||
write!(f, "{}", output) | ||
} | ||
} | ||
|
||
impl std::fmt::Display for ParserErrorChain { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
let mut output: String = "".to_string(); | ||
for (line, err) in &self.0 { | ||
output.push_str(&format!( | ||
"At line {} found error: {}\n", | ||
line.to_string(), | ||
err | ||
)); | ||
} | ||
write!(f, "{}", output) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod error; | ||
pub mod interpreter; | ||
pub mod parser; | ||
|
||
|