chore: add erg_common::io module

This commit is contained in:
Shunsuke Shibayama 2023-06-09 12:11:13 +09:00
parent 324618dbdc
commit d75ac0c17b
20 changed files with 787 additions and 749 deletions

View file

@ -7,9 +7,10 @@ use std::process;
use crate::ty::codeobj::{CodeObj, CodeObjFlags, MakeFunctionFlags};
use crate::ty::value::GenTypeObj;
use erg_common::cache::CacheSet;
use erg_common::config::{ErgConfig, Input};
use erg_common::config::ErgConfig;
use erg_common::env::erg_std_path;
use erg_common::error::{ErrorDisplay, Location};
use erg_common::io::Input;
use erg_common::opcode::{CommonOpcode, CompareOp};
use erg_common::opcode308::Opcode308;
use erg_common::opcode310::Opcode310;

View file

@ -2,9 +2,9 @@
use std::option::Option; // conflicting to Type::Option
use std::path::{Path, PathBuf};
use erg_common::config::Input;
use erg_common::consts::{ERG_MODE, PYTHON_MODE};
use erg_common::error::{ErrorCore, Location, SubMessage};
use erg_common::io::Input;
use erg_common::levenshtein;
use erg_common::set::Set;
use erg_common::traits::{Locational, NoTypeDisplay, Stream};

View file

@ -1,5 +1,5 @@
use erg_common::config::Input;
use erg_common::error::{ErrorCore, ErrorKind::*, Location, SubMessage};
use erg_common::io::Input;
use erg_common::switch_lang;
use crate::error::*;

View file

@ -1,5 +1,5 @@
use erg_common::config::Input;
use erg_common::error::{ErrorCore, ErrorKind::*, Location, SubMessage};
use erg_common::io::Input;
use erg_common::style::{StyledStr, StyledString, StyledStrings, Stylize};
use erg_common::traits::Locational;
use erg_common::{switch_lang, Str};

View file

@ -4,15 +4,15 @@ pub mod tycheck;
use std::fmt;
use erg_common::config::Input;
use erg_common::error::{
ErrorCore, ErrorDisplay, ErrorKind::*, Location, MultiErrorDisplay, SubMessage,
};
use erg_common::io::Input;
use erg_common::style::{Attribute, Color, StyledStr, StyledString, StyledStrings, Theme, THEME};
use erg_common::traits::{Locational, Stream};
use erg_common::{impl_display_and_error, impl_stream, switch_lang};
use erg_parser::error::{ParserRunnerError, ParserRunnerErrors};
use erg_parser::error::{ParseError, ParseErrors, ParserRunnerError, ParserRunnerErrors};
pub use crate::error::eval::*;
pub use crate::error::lower::*;
@ -497,6 +497,18 @@ impl From<CompileError> for CompileErrors {
}
}
impl From<CompileError> for ParseError {
fn from(err: CompileError) -> Self {
Self::new(*err.core)
}
}
impl From<CompileErrors> for ParseErrors {
fn from(err: CompileErrors) -> Self {
Self::new(err.into_iter().map(ParseError::from).collect())
}
}
impl MultiErrorDisplay<CompileError> for CompileErrors {}
impl fmt::Display for CompileErrors {
@ -524,7 +536,7 @@ mod test {
ty::{Predicate, Type},
varinfo::{AbsLocation, VarInfo},
};
use erg_common::{config::Input, error::Location};
use erg_common::{error::Location, io::Input};
use erg_parser::ast::{VarName, VisModifierSpec};
// These Erg codes are not correct grammar.

View file

@ -1,7 +1,7 @@
use std::fmt::Display;
use erg_common::config::Input;
use erg_common::error::{ErrorCore, ErrorKind::*, Location, SubMessage};
use erg_common::io::Input;
use erg_common::set::Set;
use erg_common::style::{StyledStr, StyledString, StyledStrings, Stylize};
use erg_common::traits::{Locational, NoTypeDisplay};

View file

@ -1,5 +1,6 @@
use erg_common::config::{ErgConfig, Output};
use erg_common::config::ErgConfig;
use erg_common::error::MultiErrorDisplay;
use erg_common::io::Output;
use erg_common::spawn::exec_new_thread;
use erg_common::traits::Runnable;

View file

@ -7,10 +7,10 @@ use std::hash::{Hash, Hasher};
use std::ops::Neg;
use std::sync::Arc;
use erg_common::config::Input;
use erg_common::dict::Dict;
use erg_common::error::{ErrorCore, ErrorKind, Location};
use erg_common::fresh::fresh_varname;
use erg_common::io::Input;
use erg_common::python_util::PythonVersion;
use erg_common::serialize::*;
use erg_common::set::Set;