Add `ASTBuilder`, `Checker`
This commit is contained in:
Shunsuke Shibayama 2022-09-20 14:42:37 +09:00
parent f12c2ba723
commit d8799f0895
14 changed files with 254 additions and 104 deletions

View file

@ -237,6 +237,15 @@ pub struct TyCheckError {
pub caused_by: AtomicStr,
}
impl From<ParserRunnerError> for TyCheckError {
fn from(err: ParserRunnerError) -> Self {
Self {
core: err.core,
caused_by: "".into(),
}
}
}
impl ErrorDisplay for TyCheckError {
fn core(&self) -> &ErrorCore {
&self.core
@ -1169,6 +1178,7 @@ passed keyword args: {RED}{kw_args_len}{RESET}"
pub struct TyCheckErrors(Vec<TyCheckError>);
impl_stream_for_wrapper!(TyCheckErrors, TyCheckError);
impl MultiErrorDisplay<TyCheckError> for TyCheckErrors {}
impl From<Vec<TyCheckError>> for TyCheckErrors {
fn from(errs: Vec<TyCheckError>) -> Self {
@ -1189,6 +1199,12 @@ impl From<TyCheckError> for TyCheckErrors {
}
}
impl From<ParserRunnerErrors> for TyCheckErrors {
fn from(err: ParserRunnerErrors) -> Self {
Self(err.into_iter().map(TyCheckError::from).collect())
}
}
pub type TyCheckResult<T> = Result<T, TyCheckError>;
pub type TyCheckWarning = TyCheckError;
pub type TyCheckWarnings = TyCheckErrors;