Skip to content

Commit

Permalink
refactor: using compiler base session in the kclvm parser to prepare …
Browse files Browse the repository at this point in the history
…for the parser error recovery. (#438)

* chore: remove un-used commands in makefile.

* refactor: using compiler base session in the kclvm parser to prepare for the parser error recovery.
  • Loading branch information
Peefy committed Mar 8, 2023
1 parent 4d7f3b8 commit 6674a71
Show file tree
Hide file tree
Showing 39 changed files with 560 additions and 327 deletions.
4 changes: 2 additions & 2 deletions compiler_base/session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "compiler_base_session"
version = "0.0.9"
version = "0.0.12"
edition = "2021"
authors = ["[email protected]"]
license = "Apache-2.0 OR MIT"
Expand All @@ -15,5 +15,5 @@ categories = ["command-line-utilities"]

[dependencies]
compiler_base_span = "0.0.1"
compiler_base_error = "0.0.6"
compiler_base_error = "0.0.8"
anyhow = "1.0"
20 changes: 19 additions & 1 deletion compiler_base/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Session {
pub fn emit_stashed_diagnostics(&self) -> Result<&Self> {
self.diag_handler
.emit_stashed_diagnostics()
.with_context(|| "Internale Bug: Fail to display error diagnostic")?;
.with_context(|| "Internal Bug: Fail to display error diagnostic")?;
Ok(self)
}

Expand Down Expand Up @@ -333,6 +333,24 @@ impl Session {
}
}

impl Default for Session {
/// New a default session with a empty source map.
///
/// # Examples
///
/// ```
/// use compiler_base_session::Session;
///
/// assert_eq!(Session::default().diagnostics_count().unwrap(), 0);
/// ```
fn default() -> Self {
Self {
sm: Arc::new(SourceMap::new(FilePathMapping::empty())),
diag_handler: Arc::new(DiagnosticHandler::default()),
}
}
}

/// Trait implemented by error types.
///
/// You can implement manually for error types as below.
Expand Down
2 changes: 1 addition & 1 deletion compiler_base/span/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "compiler_base_span"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
authors = ["[email protected]"]
license = "Apache-2.0 OR MIT"
Expand Down
Loading

0 comments on commit 6674a71

Please sign in to comment.