mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Rename crates
common -> erg_common compiler -> erg_compiler parser -> erg_parser
This commit is contained in:
parent
e6008e187b
commit
2a79d79a1c
73 changed files with 210 additions and 210 deletions
22
Cargo.toml
22
Cargo.toml
|
@ -9,22 +9,22 @@ edition = "2021"
|
||||||
[features]
|
[features]
|
||||||
# when "debug" feature is turned on, that of the following crates will also be turned on.
|
# when "debug" feature is turned on, that of the following crates will also be turned on.
|
||||||
debug = [
|
debug = [
|
||||||
"common/debug",
|
"erg_common/debug",
|
||||||
"parser/debug",
|
"erg_parser/debug",
|
||||||
"compiler/debug",
|
"erg_compiler/debug",
|
||||||
#"vm/debug"
|
#"erg_vm/debug"
|
||||||
]
|
]
|
||||||
japanese = [
|
japanese = [
|
||||||
"common/japanese",
|
"erg_common/japanese",
|
||||||
"parser/japanese",
|
"erg_parser/japanese",
|
||||||
"compiler/japanese",
|
"erg_compiler/japanese",
|
||||||
#"vm/japanese"
|
#"erg_vm/japanese"
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
common = { path = "./src/common" }
|
erg_common = { path = "./src/erg_common" }
|
||||||
parser = { path = "./src/compiler/parser" }
|
erg_parser = { path = "./src/erg_compiler/erg_parser" }
|
||||||
compiler = { path = "./src/compiler" }
|
erg_compiler = { path = "./src/erg_compiler" }
|
||||||
# vm = { path = "./src/vm" }
|
# vm = { path = "./src/vm" }
|
||||||
|
|
||||||
# [workspace]
|
# [workspace]
|
||||||
|
|
12
src/dummy.rs
12
src/dummy.rs
|
@ -1,10 +1,10 @@
|
||||||
use common::config::{ErgConfig, Input, SEMVER, BUILD_INFO};
|
use erg_common::config::{ErgConfig, Input, SEMVER, BUILD_INFO};
|
||||||
use common::python_util::eval_pyc;
|
use erg_common::python_util::eval_pyc;
|
||||||
use common::str::Str;
|
use erg_common::str::Str;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
use compiler::Compiler;
|
use erg_compiler::Compiler;
|
||||||
use compiler::error::{CompileError, CompileErrors};
|
use erg_compiler::error::{CompileError, CompileErrors};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DummyVM {
|
pub struct DummyVM {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "common"
|
name = "erg_common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "A common components library of Erg"
|
description = "A common components library of Erg"
|
||||||
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
|
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
|
|
@ -70,14 +70,14 @@ macro_rules! switch_lang {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! enum_unwrap {
|
macro_rules! enum_unwrap {
|
||||||
($ex: expr, $Enum: path $(,)*) => {{
|
($ex: expr, $Enum: path $(,)*) => {{
|
||||||
if let $Enum(res) = $ex { res } else { common::switch_unreachable!() }
|
if let $Enum(res) = $ex { res } else { erg_common::switch_unreachable!() }
|
||||||
}};
|
}};
|
||||||
($ex: expr, $Enum: path :( $Cons: path :(_) ) $(,)*) => {{
|
($ex: expr, $Enum: path :( $Cons: path :(_) ) $(,)*) => {{
|
||||||
if let $Enum($Cons(res)) = $ex { res } else { common::switch_unreachable!() }
|
if let $Enum($Cons(res)) = $ex { res } else { erg_common::switch_unreachable!() }
|
||||||
}};
|
}};
|
||||||
// X::A{a, b}
|
// X::A{a, b}
|
||||||
($ex: expr, $Enum: path {$($fields: ident $(,)*)*}) => {{
|
($ex: expr, $Enum: path {$($fields: ident $(,)*)*}) => {{
|
||||||
if let $Enum{$($fields,)*} = $ex { ($($fields,)*) } else { common::switch_unreachable!() }
|
if let $Enum{$($fields,)*} = $ex { ($($fields,)*) } else { erg_common::switch_unreachable!() }
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,10 +187,10 @@ macro_rules! power_assert {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! debug_power_assert {
|
macro_rules! debug_power_assert {
|
||||||
($l: expr, $op: tt, $r: expr) => {
|
($l: expr, $op: tt, $r: expr) => {
|
||||||
if cfg!(debug_assertions) { common::power_assert!($l, $op, $r) }
|
if cfg!(debug_assertions) { erg_common::power_assert!($l, $op, $r) }
|
||||||
};
|
};
|
||||||
($ex: expr) => {
|
($ex: expr) => {
|
||||||
if cfg!(debug_assertions) { common::power_assert!($ex) }
|
if cfg!(debug_assertions) { erg_common::power_assert!($ex) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ macro_rules! impl_displayable_stream_for_wrapper {
|
||||||
|
|
||||||
impl std::fmt::Display for $Strc {
|
impl std::fmt::Display for $Strc {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "[{}]", common::fmt_iter(self.iter()).replace("\n", "\\n"))
|
write!(f, "[{}]", erg_common::fmt_iter(self.iter()).replace("\n", "\\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +111,10 @@ macro_rules! impl_displayable_stream_for_wrapper {
|
||||||
|
|
||||||
impl std::ops::Index<usize> for $Strc {
|
impl std::ops::Index<usize> for $Strc {
|
||||||
type Output = $Inner;
|
type Output = $Inner;
|
||||||
fn index(&self, idx: usize) -> &Self::Output { common::traits::Stream::get(self, idx).unwrap() }
|
fn index(&self, idx: usize) -> &Self::Output { erg_common::traits::Stream::get(self, idx).unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl common::traits::Stream<$Inner> for $Strc {
|
impl erg_common::traits::Stream<$Inner> for $Strc {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn payload(self) -> Vec<$Inner> { self.0 }
|
fn payload(self) -> Vec<$Inner> { self.0 }
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -142,10 +142,10 @@ macro_rules! impl_stream_for_wrapper {
|
||||||
|
|
||||||
impl std::ops::Index<usize> for $Strc {
|
impl std::ops::Index<usize> for $Strc {
|
||||||
type Output = $Inner;
|
type Output = $Inner;
|
||||||
fn index(&self, idx: usize) -> &Self::Output { common::traits::Stream::get(self, idx).unwrap() }
|
fn index(&self, idx: usize) -> &Self::Output { erg_common::traits::Stream::get(self, idx).unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl common::traits::Stream<$Inner> for $Strc {
|
impl erg_common::traits::Stream<$Inner> for $Strc {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn payload(self) -> Vec<$Inner> { self.0 }
|
fn payload(self) -> Vec<$Inner> { self.0 }
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -159,7 +159,7 @@ macro_rules! impl_stream_for_wrapper {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_stream {
|
macro_rules! impl_stream {
|
||||||
($Strc: ident, $Inner: ident, $field: ident) => {
|
($Strc: ident, $Inner: ident, $field: ident) => {
|
||||||
impl common::traits::Stream<$Inner> for $Strc {
|
impl erg_common::traits::Stream<$Inner> for $Strc {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn payload(self) -> Vec<$Inner> { self.$field }
|
fn payload(self) -> Vec<$Inner> { self.$field }
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -170,7 +170,7 @@ macro_rules! impl_stream {
|
||||||
|
|
||||||
impl std::ops::Index<usize> for $Strc {
|
impl std::ops::Index<usize> for $Strc {
|
||||||
type Output = $Inner;
|
type Output = $Inner;
|
||||||
fn index(&self, idx: usize) -> &Self::Output { common::traits::Stream::get(self, idx).unwrap() }
|
fn index(&self, idx: usize) -> &Self::Output { erg_common::traits::Stream::get(self, idx).unwrap() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,8 +320,8 @@ pub trait Locational {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_locational_for_enum {
|
macro_rules! impl_locational_for_enum {
|
||||||
($Enum: ident; $($Variant: ident $(,)?)*) => {
|
($Enum: ident; $($Variant: ident $(,)?)*) => {
|
||||||
impl common::traits::Locational for $Enum {
|
impl erg_common::traits::Locational for $Enum {
|
||||||
fn loc(&self) -> common::error::Location {
|
fn loc(&self) -> erg_common::error::Location {
|
||||||
match self {
|
match self {
|
||||||
$($Enum::$Variant(v) => v.loc(),)*
|
$($Enum::$Variant(v) => v.loc(),)*
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ pub trait HasType {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_t {
|
macro_rules! impl_t {
|
||||||
($T: ty, $t: ident) => {
|
($T: ty, $t: ident) => {
|
||||||
impl common::traits::HasType for $T {
|
impl erg_common::traits::HasType for $T {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ref_t(&self) -> &common::ty::Type { &common::ty::Type::$t }
|
fn ref_t(&self) -> &common::ty::Type { &common::ty::Type::$t }
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "compiler"
|
name = "erg_compiler"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Centimetre: the Erg compiler"
|
description = "Centimetre: the Erg compiler"
|
||||||
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
|
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
|
||||||
|
@ -8,12 +8,12 @@ edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# when "debug" feature is turned on, that of parser will also be turned on.
|
# when "debug" feature is turned on, that of parser will also be turned on.
|
||||||
debug = [ "common/debug", "parser/debug" ]
|
debug = [ "erg_common/debug", "erg_parser/debug" ]
|
||||||
japanese = [ "common/japanese", "parser/japanese" ]
|
japanese = [ "erg_common/japanese", "erg_parser/japanese" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
common = { path = "../common" }
|
erg_common = { path = "../erg_common" }
|
||||||
parser = { path = "parser" }
|
erg_parser = { path = "erg_parser" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
|
@ -4,21 +4,21 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::cache::Cache;
|
use erg_common::cache::Cache;
|
||||||
use common::{fn_name_full, enum_unwrap, switch_unreachable, debug_power_assert, log, impl_stream_for_wrapper};
|
use erg_common::{fn_name_full, enum_unwrap, switch_unreachable, debug_power_assert, log, impl_stream_for_wrapper};
|
||||||
use common::codeobj::{CodeObj, CodeObjFlags};
|
use erg_common::codeobj::{CodeObj, CodeObjFlags};
|
||||||
use common::color::{GREEN, RESET};
|
use erg_common::color::{GREEN, RESET};
|
||||||
use common::config::{ErgConfig, Input};
|
use erg_common::config::{ErgConfig, Input};
|
||||||
use common::error::{Location, MultiErrorDisplay};
|
use erg_common::error::{Location, MultiErrorDisplay};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::opcode::Opcode;
|
use erg_common::opcode::Opcode;
|
||||||
use Opcode::*;
|
use Opcode::*;
|
||||||
use common::traits::{HasType, Locational, Stream};
|
use erg_common::traits::{HasType, Locational, Stream};
|
||||||
use common::ty::{TypeCode, TypePair};
|
use erg_common::ty::{TypeCode, TypePair};
|
||||||
|
|
||||||
use parser::token::{Token, TokenKind, TokenCategory};
|
use erg_parser::token::{Token, TokenKind, TokenCategory};
|
||||||
use parser::ast::{VarPattern, ParamPattern, Params};
|
use erg_parser::ast::{VarPattern, ParamPattern, Params};
|
||||||
|
|
||||||
use crate::compile::{AccessKind, Name, StoreLoadKind};
|
use crate::compile::{AccessKind, Name, StoreLoadKind};
|
||||||
use crate::error::{CompileError, CompileErrors, CompileResult};
|
use crate::error::{CompileError, CompileErrors, CompileResult};
|
|
@ -3,15 +3,15 @@
|
||||||
//! コンパイラーを定義する
|
//! コンパイラーを定義する
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::{log};
|
use erg_common::{log};
|
||||||
use common::codeobj::{CodeObj, CodeObjFlags};
|
use erg_common::codeobj::{CodeObj, CodeObjFlags};
|
||||||
use common::color::{GREEN, RESET};
|
use erg_common::color::{GREEN, RESET};
|
||||||
use common::config::{Input, ErgConfig, SEMVER, BUILD_INFO};
|
use erg_common::config::{Input, ErgConfig, SEMVER, BUILD_INFO};
|
||||||
use common::error::MultiErrorDisplay;
|
use erg_common::error::MultiErrorDisplay;
|
||||||
use common::traits::{Runnable, Stream};
|
use erg_common::traits::{Runnable, Stream};
|
||||||
|
|
||||||
use parser::ParserRunner;
|
use erg_parser::ParserRunner;
|
||||||
|
|
||||||
use crate::codegen::CodeGenerator;
|
use crate::codegen::CodeGenerator;
|
||||||
use crate::effectcheck::SideEffectChecker;
|
use crate::effectcheck::SideEffectChecker;
|
|
@ -2,10 +2,10 @@
|
||||||
//! SideEffectCheckerを実装
|
//! SideEffectCheckerを実装
|
||||||
//! 関数や不変型に副作用がないかチェックする
|
//! 関数や不変型に副作用がないかチェックする
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::color::{GREEN, RESET};
|
use erg_common::color::{GREEN, RESET};
|
||||||
use common::log;
|
use erg_common::log;
|
||||||
use common::traits::Stream;
|
use erg_common::traits::Stream;
|
||||||
|
|
||||||
use crate::varinfo::Visibility;
|
use crate::varinfo::Visibility;
|
||||||
use Visibility::*;
|
use Visibility::*;
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "parser"
|
name = "erg_parser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "The Erg parser"
|
description = "The Erg parser"
|
||||||
authors = ["mtshiba <sbym1346@gmail.com>"]
|
authors = ["mtshiba <sbym1346@gmail.com>"]
|
||||||
|
@ -7,11 +7,11 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
debug = [ "common/debug" ]
|
debug = [ "erg_common/debug" ]
|
||||||
japanese = [ "common/japanese" ]
|
japanese = [ "erg_common/japanese" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
common = { path = "../../common" }
|
erg_common = { path = "../../erg_common" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
|
@ -2,8 +2,8 @@
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use common::{Str};
|
use erg_common::{Str};
|
||||||
use common::{
|
use erg_common::{
|
||||||
impl_display_for_single_struct,
|
impl_display_for_single_struct,
|
||||||
impl_locational, impl_locational_for_enum,
|
impl_locational, impl_locational_for_enum,
|
||||||
impl_displayable_stream_for_wrapper,
|
impl_displayable_stream_for_wrapper,
|
||||||
|
@ -11,11 +11,11 @@ use common::{
|
||||||
fmt_vec, fmt_option, impl_display_for_enum,
|
fmt_vec, fmt_option, impl_display_for_enum,
|
||||||
impl_display_from_nested, impl_nested_display_for_enum
|
impl_display_from_nested, impl_nested_display_for_enum
|
||||||
};
|
};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::error::Location;
|
use erg_common::error::Location;
|
||||||
use common::set::Set;
|
use erg_common::set::Set;
|
||||||
use common::traits::{Locational, Stream, NestedDisplay};
|
use erg_common::traits::{Locational, Stream, NestedDisplay};
|
||||||
use common::ty::SubrKind;
|
use erg_common::ty::SubrKind;
|
||||||
|
|
||||||
use crate::token::{Token, TokenKind};
|
use crate::token::{Token, TokenKind};
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
//! 型チェックなどによる検証は行わない
|
//! 型チェックなどによる検証は行わない
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use common::{enum_unwrap, set};
|
use erg_common::{enum_unwrap, set};
|
||||||
use common::{Str};
|
use erg_common::{Str};
|
||||||
use common::set::{Set};
|
use erg_common::set::{Set};
|
||||||
use common::traits::{Stream, Locational};
|
use erg_common::traits::{Stream, Locational};
|
||||||
|
|
||||||
use crate::token::{Token, TokenKind};
|
use crate::token::{Token, TokenKind};
|
||||||
use crate::ast::{
|
use crate::ast::{
|
|
@ -1,11 +1,11 @@
|
||||||
//! defines `ParseError` and others.
|
//! defines `ParseError` and others.
|
||||||
//!
|
//!
|
||||||
//! パーサーが出すエラーを定義
|
//! パーサーが出すエラーを定義
|
||||||
use common::{impl_stream_for_wrapper, switch_lang};
|
use erg_common::{impl_stream_for_wrapper, switch_lang};
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::config::Input;
|
use erg_common::config::Input;
|
||||||
use common::error::{ErrorCore, ErrorDisplay, MultiErrorDisplay, Location, ErrorKind::*};
|
use erg_common::error::{ErrorCore, ErrorDisplay, MultiErrorDisplay, Location, ErrorKind::*};
|
||||||
use common::traits::Stream;
|
use erg_common::traits::Stream;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LexError(ErrorCore);
|
pub struct LexError(ErrorCore);
|
|
@ -1,10 +1,10 @@
|
||||||
//! defines and implements `Lexer` (Tokenizer).
|
//! defines and implements `Lexer` (Tokenizer).
|
||||||
use common::cache::Cache;
|
use erg_common::cache::Cache;
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::{fn_name_full, switch_lang, debug_power_assert, normalize_newline};
|
use erg_common::{fn_name_full, switch_lang, debug_power_assert, normalize_newline};
|
||||||
use common::config::Input;
|
use erg_common::config::Input;
|
||||||
use common::config::ErgConfig;
|
use erg_common::config::ErgConfig;
|
||||||
use common::traits::{Locational, Runnable, Stream};
|
use erg_common::traits::{Locational, Runnable, Stream};
|
||||||
|
|
||||||
use crate::error::{LexerRunnerError, LexerRunnerErrors, LexError, LexErrors, LexResult};
|
use crate::error::{LexerRunnerError, LexerRunnerErrors, LexError, LexErrors, LexResult};
|
||||||
use crate::token::{Token, TokenCategory, TokenKind, TokenStream};
|
use crate::token::{Token, TokenCategory, TokenKind, TokenStream};
|
|
@ -1,6 +1,6 @@
|
||||||
//! Implements `Parser` for Erg. `Parser` parses the source code to generate `AST`,
|
//! Implements `Parser` for Erg. `Parser` parses the source code to generate `AST`,
|
||||||
//! and performs type checking and other optimizations if necessary.
|
//! and performs type checking and other optimizations if necessary.
|
||||||
extern crate common;
|
extern crate erg_common;
|
||||||
|
|
||||||
pub mod desugar;
|
pub mod desugar;
|
||||||
pub mod error;
|
pub mod error;
|
|
@ -3,11 +3,11 @@ extern crate parser;
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use common::config::ErgConfig;
|
use erg_common::config::ErgConfig;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
use parser::lex::LexerRunner;
|
use erg_parser::lex::LexerRunner;
|
||||||
use parser::ParserRunner;
|
use erg_parser::ParserRunner;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cfg = ErgConfig::parse();
|
let cfg = ErgConfig::parse();
|
|
@ -5,15 +5,15 @@
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::{debug_power_assert, enum_unwrap, fn_name, caused_by, switch_lang, switch_unreachable, log, set};
|
use erg_common::{debug_power_assert, enum_unwrap, fn_name, caused_by, switch_lang, switch_unreachable, log, set};
|
||||||
use common::color::{GREEN, RED, RESET};
|
use erg_common::color::{GREEN, RED, RESET};
|
||||||
use common::config::{Input, SEMVER, BUILD_INFO};
|
use erg_common::config::{Input, SEMVER, BUILD_INFO};
|
||||||
use common::config::ErgConfig;
|
use erg_common::config::ErgConfig;
|
||||||
use common::error::{Location};
|
use erg_common::error::{Location};
|
||||||
use common::set::Set;
|
use erg_common::set::Set;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
use common::traits::{Locational, Stream};
|
use erg_common::traits::{Locational, Stream};
|
||||||
|
|
||||||
use crate::error::{ParseError, ParseErrors, ParseResult, ParserRunnerError, ParserRunnerErrors};
|
use crate::error::{ParseError, ParseErrors, ParseResult, ParserRunnerError, ParserRunnerErrors};
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
|
@ -4,16 +4,16 @@ extern crate parser;
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
|
|
||||||
use common::config::{ErgConfig, Input};
|
use erg_common::config::{ErgConfig, Input};
|
||||||
use common::error::MultiErrorFmt;
|
use erg_common::error::MultiErrorFmt;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
// use compiler::parser;
|
// use erg_compiler::parser;
|
||||||
|
|
||||||
use parser::error::*;
|
use erg_parser::error::*;
|
||||||
use parser::lex::Lexer;
|
use erg_parser::lex::Lexer;
|
||||||
use parser::token::*;
|
use erg_parser::token::*;
|
||||||
use parser::ParserRunner;
|
use erg_parser::ParserRunner;
|
||||||
use TokenKind::*;
|
use TokenKind::*;
|
||||||
|
|
||||||
const FILE1: &str = "src/compiler/parser/tests/test1_basic_syntax.er";
|
const FILE1: &str = "src/compiler/parser/tests/test1_basic_syntax.er";
|
|
@ -4,12 +4,12 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
use common::str::Str;
|
use erg_common::str::Str;
|
||||||
use common::error::Location;
|
use erg_common::error::Location;
|
||||||
use common::impl_displayable_stream_for_wrapper;
|
use erg_common::impl_displayable_stream_for_wrapper;
|
||||||
use common::traits::{Stream, Locational};
|
use erg_common::traits::{Stream, Locational};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::ty::Type;
|
use erg_common::ty::Type;
|
||||||
|
|
||||||
/// 意味論的名前と記号自体の名前が混在しているが、Pythonの名残である
|
/// 意味論的名前と記号自体の名前が混在しているが、Pythonの名残である
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
@ -1,15 +1,15 @@
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
use common::color::{GREEN, RED, YELLOW, RESET};
|
use erg_common::color::{GREEN, RED, YELLOW, RESET};
|
||||||
use common::config::Input;
|
use erg_common::config::Input;
|
||||||
use common::error::{ErrorCore, ErrorKind::*, ErrorDisplay, MultiErrorDisplay, Location};
|
use erg_common::error::{ErrorCore, ErrorKind::*, ErrorDisplay, MultiErrorDisplay, Location};
|
||||||
use common::traits::{Stream, Locational};
|
use erg_common::traits::{Stream, Locational};
|
||||||
use common::ty::{Type, Predicate};
|
use erg_common::ty::{Type, Predicate};
|
||||||
use common::{Str, fmt_iter};
|
use erg_common::{Str, fmt_iter};
|
||||||
use common::{impl_stream_for_wrapper, switch_lang};
|
use erg_common::{impl_stream_for_wrapper, switch_lang};
|
||||||
|
|
||||||
use parser::error::{ParserRunnerError, ParserRunnerErrors};
|
use erg_parser::error::{ParserRunnerError, ParserRunnerErrors};
|
||||||
|
|
||||||
use crate::hir::Expr;
|
use crate::hir::Expr;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::{fn_name, set};
|
use erg_common::{fn_name, set};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::dict::Dict;
|
use erg_common::dict::Dict;
|
||||||
use common::rccell::RcCell;
|
use erg_common::rccell::RcCell;
|
||||||
use common::set::{Set};
|
use erg_common::set::{Set};
|
||||||
use common::traits::Stream;
|
use erg_common::traits::Stream;
|
||||||
use common::ty::{OpKind, TyParam, Type, Predicate, TyBound, ConstObj, SubrKind};
|
use erg_common::ty::{OpKind, TyParam, Type, Predicate, TyBound, ConstObj, SubrKind};
|
||||||
use OpKind::*;
|
use OpKind::*;
|
||||||
|
|
||||||
use parser::ast::*;
|
use erg_parser::ast::*;
|
||||||
use parser::token::Token;
|
use erg_parser::token::Token;
|
||||||
|
|
||||||
use crate::table::{SymbolTable, TyVarTable};
|
use crate::table::{SymbolTable, TyVarTable};
|
||||||
use crate::error::{EvalError, EvalResult, TyCheckResult};
|
use crate::error::{EvalError, EvalResult, TyCheckResult};
|
|
@ -1,19 +1,19 @@
|
||||||
/// defines High-level Intermediate Representation
|
/// defines High-level Intermediate Representation
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use common::{Str};
|
use erg_common::{Str};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::error::Location;
|
use erg_common::error::Location;
|
||||||
use common::traits::{HasType, Locational, Stream, NestedDisplay};
|
use erg_common::traits::{HasType, Locational, Stream, NestedDisplay};
|
||||||
use common::ty::{Type, TyParam, Constraint};
|
use erg_common::ty::{Type, TyParam, Constraint};
|
||||||
use common::{
|
use erg_common::{
|
||||||
impl_locational, impl_locational_for_enum,
|
impl_locational, impl_locational_for_enum,
|
||||||
impl_stream_for_wrapper, impl_display_for_enum,
|
impl_stream_for_wrapper, impl_display_for_enum,
|
||||||
impl_nested_display_for_enum, impl_display_from_nested,
|
impl_nested_display_for_enum, impl_display_from_nested,
|
||||||
};
|
};
|
||||||
|
|
||||||
use parser::token::{Token, TokenKind};
|
use erg_parser::token::{Token, TokenKind};
|
||||||
use parser::ast::{VarName, VarPattern, Params, DefId, fmt_lines};
|
use erg_parser::ast::{VarName, VarPattern, Params, DefId, fmt_lines};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Literal {
|
pub struct Literal {
|
|
@ -1,14 +1,14 @@
|
||||||
//! defines type information for builtin objects (in `SymbolTable`)
|
//! defines type information for builtin objects (in `SymbolTable`)
|
||||||
//!
|
//!
|
||||||
//! 組み込みオブジェクトの型情報を(記号表に)定義
|
//! 組み込みオブジェクトの型情報を(記号表に)定義
|
||||||
use common::{Str};
|
use erg_common::{Str};
|
||||||
use common::{set, debug_power_assert};
|
use erg_common::{set, debug_power_assert};
|
||||||
use common::ty::{Type, TyParam, ConstObj};
|
use erg_common::ty::{Type, TyParam, ConstObj};
|
||||||
use Type::*;
|
use Type::*;
|
||||||
use common::ty::type_constrs::*;
|
use erg_common::ty::type_constrs::*;
|
||||||
use ParamSpec as PS;
|
use ParamSpec as PS;
|
||||||
|
|
||||||
use parser::ast::{VarName};
|
use erg_parser::ast::{VarName};
|
||||||
|
|
||||||
use crate::varinfo::{Mutability, Visibility, VarInfo, VarKind};
|
use crate::varinfo::{Mutability, Visibility, VarInfo, VarKind};
|
||||||
use crate::table::{SymbolTable, ParamSpec, DefaultInfo};
|
use crate::table::{SymbolTable, ParamSpec, DefaultInfo};
|
|
@ -1,6 +1,6 @@
|
||||||
//! defines the compiler for Erg (ergc).
|
//! defines the compiler for Erg (ergc).
|
||||||
extern crate common;
|
extern crate erg_common;
|
||||||
pub extern crate parser;
|
pub extern crate erg_parser;
|
||||||
|
|
||||||
mod compile;
|
mod compile;
|
||||||
pub use compile::*;
|
pub use compile::*;
|
|
@ -1,15 +1,15 @@
|
||||||
//! implements `ASTLowerer`.
|
//! implements `ASTLowerer`.
|
||||||
//!
|
//!
|
||||||
//! ASTLowerer(ASTからHIRへの変換器)を実装
|
//! ASTLowerer(ASTからHIRへの変換器)を実装
|
||||||
use common::{switch_lang, log, fn_name};
|
use erg_common::{switch_lang, log, fn_name};
|
||||||
use common::color::{GREEN, RED, RESET};
|
use erg_common::color::{GREEN, RED, RESET};
|
||||||
use common::error::Location;
|
use erg_common::error::Location;
|
||||||
use common::traits::{Locational, Stream, HasType};
|
use erg_common::traits::{Locational, Stream, HasType};
|
||||||
use common::ty::{Type, ParamTy};
|
use erg_common::ty::{Type, ParamTy};
|
||||||
use common::get_hash;
|
use erg_common::get_hash;
|
||||||
|
|
||||||
use parser::ast;
|
use erg_parser::ast;
|
||||||
use parser::ast::{AST};
|
use erg_parser::ast::{AST};
|
||||||
|
|
||||||
use crate::hir;
|
use crate::hir;
|
||||||
use crate::hir::{HIR};
|
use crate::hir::{HIR};
|
|
@ -1,17 +1,17 @@
|
||||||
extern crate common;
|
extern crate erg_common;
|
||||||
extern crate compiler;
|
extern crate erg_compiler;
|
||||||
extern crate parser;
|
extern crate erg_parser;
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use common::deserialize::Deserializer;
|
use erg_common::deserialize::Deserializer;
|
||||||
use common::config::{ErgConfig};
|
use erg_common::config::{ErgConfig};
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
use compiler::Compiler;
|
use erg_compiler::Compiler;
|
||||||
|
|
||||||
use parser::lex::LexerRunner;
|
use erg_parser::lex::LexerRunner;
|
||||||
use parser::ParserRunner;
|
use erg_parser::ParserRunner;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cfg = ErgConfig::parse();
|
let cfg = ErgConfig::parse();
|
|
@ -1,11 +1,11 @@
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::{debug_power_assert, log};
|
use erg_common::{debug_power_assert, log};
|
||||||
use common::color::{GREEN, RESET};
|
use erg_common::color::{GREEN, RESET};
|
||||||
use common::dict::Dict;
|
use erg_common::dict::Dict;
|
||||||
use common::error::Location;
|
use erg_common::error::Location;
|
||||||
use common::set::Set;
|
use erg_common::set::Set;
|
||||||
use common::traits::{Stream, Locational, HasType};
|
use erg_common::traits::{Stream, Locational, HasType};
|
||||||
use common::ty::{Type, ArgsOwnership, Ownership};
|
use erg_common::ty::{Type, ArgsOwnership, Ownership};
|
||||||
|
|
||||||
use crate::error::{OwnershipError, OwnershipErrors, OwnershipResult};
|
use crate::error::{OwnershipError, OwnershipErrors, OwnershipResult};
|
||||||
use crate::hir::{HIR, Def, Signature, Accessor, Block, Expr};
|
use crate::hir::{HIR, Def, Signature, Accessor, Block, Expr};
|
|
@ -6,18 +6,18 @@ use std::mem;
|
||||||
use std::option::Option; // conflicting to Type::Option
|
use std::option::Option; // conflicting to Type::Option
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::ty::Constraint;
|
use erg_common::ty::Constraint;
|
||||||
use common::ty::RefinementType;
|
use erg_common::ty::RefinementType;
|
||||||
use common::ty::fresh_varname;
|
use erg_common::ty::fresh_varname;
|
||||||
use common::{fn_name, get_hash, log, assume_unreachable, set, try_map, fmt_slice};
|
use erg_common::{fn_name, get_hash, log, assume_unreachable, set, try_map, fmt_slice};
|
||||||
use common::dict::Dict;
|
use erg_common::dict::Dict;
|
||||||
use common::set::Set;
|
use erg_common::set::Set;
|
||||||
use common::error::{Location, ErrorCore};
|
use erg_common::error::{Location, ErrorCore};
|
||||||
use common::value::ValueObj;
|
use erg_common::value::ValueObj;
|
||||||
use common::levenshtein::levenshtein;
|
use erg_common::levenshtein::levenshtein;
|
||||||
use common::traits::{HasType, Locational, Stream};
|
use erg_common::traits::{HasType, Locational, Stream};
|
||||||
use common::ty::{
|
use erg_common::ty::{
|
||||||
Type, TyParam, TyParamOrdering, TyBound, ConstObj,
|
Type, TyParam, TyParamOrdering, TyBound, ConstObj,
|
||||||
IntervalOp, FreeKind, HasLevel, SubrKind, SubrType, ParamTy, Predicate,
|
IntervalOp, FreeKind, HasLevel, SubrKind, SubrType, ParamTy, Predicate,
|
||||||
};
|
};
|
||||||
|
@ -26,9 +26,9 @@ use Type::*;
|
||||||
use Predicate as Pred;
|
use Predicate as Pred;
|
||||||
use ValueObj::{Inf, NegInf};
|
use ValueObj::{Inf, NegInf};
|
||||||
|
|
||||||
use parser::ast;
|
use erg_parser::ast;
|
||||||
use ast::{VarName, DefId, TypeSpec, ParamTySpec, PreDeclTypeSpec, SimpleTypeSpec, TypeBoundSpec, TypeBoundSpecs, ParamSig};
|
use ast::{VarName, DefId, TypeSpec, ParamTySpec, PreDeclTypeSpec, SimpleTypeSpec, TypeBoundSpec, TypeBoundSpecs, ParamSig};
|
||||||
use parser::token::{Token, TokenKind};
|
use erg_parser::token::{Token, TokenKind};
|
||||||
|
|
||||||
use crate::hir;
|
use crate::hir;
|
||||||
use crate::eval::{Evaluator};
|
use crate::eval::{Evaluator};
|
||||||
|
@ -1725,7 +1725,7 @@ impl SymbolTable {
|
||||||
// Never or T => T
|
// Never or T => T
|
||||||
let mut union_pat_t = Type::Never;
|
let mut union_pat_t = Type::Never;
|
||||||
for (i, a) in pos_args.iter().skip(1).enumerate() {
|
for (i, a) in pos_args.iter().skip(1).enumerate() {
|
||||||
let lambda = common::enum_unwrap!(&a.expr, hir::Expr::Lambda);
|
let lambda = erg_common::enum_unwrap!(&a.expr, hir::Expr::Lambda);
|
||||||
if !lambda.params.defaults.is_empty() { todo!() }
|
if !lambda.params.defaults.is_empty() { todo!() }
|
||||||
if lambda.params.len() != 1 {
|
if lambda.params.len() != 1 {
|
||||||
return Err(TyCheckError::argument_error(
|
return Err(TyCheckError::argument_error(
|
||||||
|
@ -1819,7 +1819,7 @@ impl SymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_binop_t(&self, op: &Token, args: &[hir::PosArg], namespace: &Str) -> TyCheckResult<Type> {
|
pub(crate) fn get_binop_t(&self, op: &Token, args: &[hir::PosArg], namespace: &Str) -> TyCheckResult<Type> {
|
||||||
common::debug_power_assert!(args.len() == 2);
|
erg_common::debug_power_assert!(args.len() == 2);
|
||||||
let symbol = Token::symbol(binop_to_dname(op.inspect()));
|
let symbol = Token::symbol(binop_to_dname(op.inspect()));
|
||||||
let mut op = hir::Expr::Accessor(hir::Accessor::local(symbol, Type::ASTOmitted));
|
let mut op = hir::Expr::Accessor(hir::Accessor::local(symbol, Type::ASTOmitted));
|
||||||
self.get_call_t(&mut op, args, &[], namespace).map_err(|e| {
|
self.get_call_t(&mut op, args, &[], namespace).map_err(|e| {
|
||||||
|
@ -1830,7 +1830,7 @@ impl SymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_unaryop_t(&self, op: &Token, args: &[hir::PosArg], namespace: &Str) -> TyCheckResult<Type> {
|
pub(crate) fn get_unaryop_t(&self, op: &Token, args: &[hir::PosArg], namespace: &Str) -> TyCheckResult<Type> {
|
||||||
common::debug_power_assert!(args.len() == 1);
|
erg_common::debug_power_assert!(args.len() == 1);
|
||||||
let symbol = Token::symbol(unaryop_to_dname(op.inspect()));
|
let symbol = Token::symbol(unaryop_to_dname(op.inspect()));
|
||||||
let mut op = hir::Expr::Accessor(hir::Accessor::local(symbol, Type::ASTOmitted));
|
let mut op = hir::Expr::Accessor(hir::Accessor::local(symbol, Type::ASTOmitted));
|
||||||
self.get_call_t(&mut op, args, &[], namespace).map_err(|e| {
|
self.get_call_t(&mut op, args, &[], namespace).map_err(|e| {
|
||||||
|
@ -2191,7 +2191,7 @@ impl SymbolTable {
|
||||||
(l, r @ (TyParam::Erased(_) | TyParam::MonoQVar(_) | TyParam::FreeVar(_))) =>
|
(l, r @ (TyParam::Erased(_) | TyParam::MonoQVar(_) | TyParam::FreeVar(_))) =>
|
||||||
self.try_cmp(r, l, bounds).map(|ord| ord.reverse()),
|
self.try_cmp(r, l, bounds).map(|ord| ord.reverse()),
|
||||||
(_l, _r) => {
|
(_l, _r) => {
|
||||||
common::fmt_dbg!(_l, _r,);
|
erg_common::fmt_dbg!(_l, _r,);
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use common::Str;
|
use erg_common::Str;
|
||||||
use common::ty::{Type};
|
use erg_common::ty::{Type};
|
||||||
use common::traits::HasType;
|
use erg_common::traits::HasType;
|
||||||
|
|
||||||
use parser::ast::DefId;
|
use erg_parser::ast::DefId;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
|
@ -1,3 +1,3 @@
|
||||||
extern crate common;
|
extern crate erg_common;
|
||||||
extern crate compiler;
|
extern crate erg_compiler;
|
||||||
pub mod dummy;
|
pub mod dummy;
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -1,17 +1,17 @@
|
||||||
extern crate compiler;
|
extern crate erg_compiler;
|
||||||
extern crate parser;
|
extern crate erg_parser;
|
||||||
extern crate erg;
|
extern crate erg;
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use common::config::{ErgConfig};
|
use erg_common::config::{ErgConfig};
|
||||||
use common::deserialize::Deserializer;
|
use erg_common::deserialize::Deserializer;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
use parser::lex::LexerRunner;
|
use erg_parser::lex::LexerRunner;
|
||||||
use parser::ParserRunner;
|
use erg_parser::ParserRunner;
|
||||||
|
|
||||||
use compiler::Compiler;
|
use erg_compiler::Compiler;
|
||||||
|
|
||||||
use erg::dummy::DummyVM;
|
use erg::dummy::DummyVM;
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ extern crate erg;
|
||||||
|
|
||||||
mod tests {
|
mod tests {
|
||||||
/*
|
/*
|
||||||
use common::config::{ErgConfig, Input};
|
use erg_common::config::{ErgConfig, Input};
|
||||||
use common::error::MultiErrorFmt;
|
use erg_common::error::MultiErrorFmt;
|
||||||
use common::traits::Runnable;
|
use erg_common::traits::Runnable;
|
||||||
|
|
||||||
const FILE3: &str = "tests/test3_object_system.er";
|
const FILE3: &str = "tests/test3_object_system.er";
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue