Skip to content

Commit

Permalink
pub use mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Nov 18, 2023
1 parent 7d86f3a commit de0e0a3
Show file tree
Hide file tree
Showing 138 changed files with 363 additions and 353 deletions.
4 changes: 2 additions & 2 deletions src/eval/env/expr_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::rc::Rc;

use crate::eval::Expr;
use crate::eval::Type;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;

// 某些表达式可能是递归定义的(常见于顶层环境和 Let)
// 对于这样的表达式, 其求值环境将具具备自引用结构
Expand Down
13 changes: 5 additions & 8 deletions src/eval/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ use crate::infer::infer_type_of_defs::{
infer_type_of_defs,
InferErr
};
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::vec::VecExt;
use crate::infra::RcAnyExt;
use crate::infra::VecExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;
use crate::lexer::lexical_analyze;
use crate::parser::ast::parse_ast;
use crate::parser::expr::r#type::{
Expr as CtExpr,
OptExpr as OptCtExpr
};
use crate::parser::r#type::r#type::{
OptType as OptCtType,
Type as CtType
};
use crate::parser::r#type::{OptType as OptCtType, Type as CtType};
use crate::pp::preprocess;

mod expr_env;
Expand Down
2 changes: 1 addition & 1 deletion src/eval/env/type_env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeSet;

use crate::eval::Type;
use crate::infra::option::WrapOption;
use crate::infra::WrapOption;

pub type TypeEnvEntry = (String, Type);

Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/case/apply/fn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::eval::EvalErr;
use crate::eval::Expr;
use crate::eval::Type;
use crate::eval::{false_type, namely_type, true_type};
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

mod primitive_apply;
mod source_lhs_to_closure;
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/apply/fn/primitive_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::eval::eval_expr::case::apply::{
use crate::eval::eval_expr::EvalRet;
use crate::eval::Expr;
use crate::eval::PrimitiveOp;
use crate::infra::option::WrapOption;
use crate::infra::result::WrapResult;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

pub fn primitive_apply(
type_env: &TypeEnv,
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/apply/fn/source_lhs_to_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::eval::EvalErr;
use crate::eval::Expr;
use crate::eval::PrimitiveOp;
use crate::eval::Type;
use crate::infra::either::{Either, EitherAnyExt};
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;
use crate::infra::{Either, EitherAnyExt};

pub fn source_lhs_expr_to_closure(
type_env: &'_ TypeEnv,
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/apply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::eval::eval_expr::case::apply::primitive_apply;
use crate::eval::eval_expr::case::apply::source_lhs_expr_to_closure;
use crate::eval::eval_expr::{eval_expr, EvalRet};
use crate::eval::Expr;
use crate::infra::either::Either;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::Either;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;

mod r#fn;
pub use r#fn::*;
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/apply/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::eval::PrimitiveOp;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

// neg 10
#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/closure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::eval::env::ExprEnv;
use crate::eval::eval_expr::EvalRet;
use crate::eval::Expr;
use crate::eval::Type;
use crate::infra::option::WrapOption;
use crate::infra::result::WrapResult;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

#[cfg(test)]
mod test;
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/closure/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::Expr;
use crate::eval::{closure_type, namely_type};
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

// (a: Int) -> 1
#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/cond/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// if false then 10 else 20
#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/discard.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::eval::eval_expr::EvalRet;
use crate::eval::EvalErr;
use crate::eval::Type;
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

pub fn case_discard(type_annot: &Type) -> EvalRet {
EvalErr::EvalDiscard(format!("Trying to eval _:{type_annot:?}"))
Expand All @@ -17,7 +17,7 @@ mod test {
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

// _: Int
#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/case/env_ref/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::{eval_expr, EvalRet};
use crate::eval::EvalErr;
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

pub fn case_env_ref(
type_env: &TypeEnv,
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/env_ref/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

// def a = 10
#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/int.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::eval::eval_expr::EvalRet;
use crate::eval::Expr;
use crate::eval::Type;
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

pub fn case_int(type_annot: &Type, int_value: &i64) -> EvalRet {
Expr::Int(type_annot.clone(), *int_value).wrap_ok()
Expand All @@ -14,8 +14,8 @@ mod test {
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// 10: Int
#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/let/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::{eval_expr, EvalRet};
use crate::eval::Expr;
use crate::eval::Type;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;

pub fn case_let(
type_env: &TypeEnv,
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/let/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// let a = 10 in a
#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/match/fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::rc::Rc;
use crate::eval::env::TypeEnv;
use crate::eval::env::{ExprEnv, ExprEnvEntry};
use crate::eval::{Expr, StructField};
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;

fn is_struct_match_pattern_then_env_vec(
type_env: &TypeEnv,
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/match/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::eval::eval_expr::case::r#match::is_expr_match_pattern_then_env;
use crate::eval::eval_expr::{eval_expr, EvalRet};
use crate::eval::EvalErr;
use crate::eval::Expr;
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

pub fn case_match(
type_env: &TypeEnv,
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/match/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::EvalErr;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// match 5 with
// | 10 -> 1
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/case/primitive_op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::eval::eval_expr::EvalRet;
use crate::eval::Expr;
use crate::eval::PrimitiveOp;
use crate::eval::Type;
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

#[cfg(test)]
mod test;
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/primitive_op/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::eval::eval_expr::eval_expr;
use crate::eval::Expr;
use crate::eval::PrimitiveOp;
use crate::eval::{closure_type, namely_type};
use crate::infra::option::WrapOption;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapOption;
use crate::infra::WrapResult;

// add
#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/struct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::eval::eval_expr::{eval_expr, EvalRet};
use crate::eval::EvalErr;
use crate::eval::Type;
use crate::eval::{Expr, StructField};
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::vec::VecExt;
use crate::infra::RcAnyExt;
use crate::infra::VecExt;
use crate::infra::WrapResult;

pub fn case_struct(
type_env: &TypeEnv,
Expand Down
4 changes: 2 additions & 2 deletions src/eval/eval_expr/case/struct/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::Expr;
use crate::eval::{namely_type, prod_type};
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// { a: Int = 10, b: Bool = true, c: Unit = ()}
#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/eval/eval_expr/case/unit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::eval::eval_expr::EvalRet;
use crate::eval::Expr;
use crate::eval::Type;
use crate::infra::result::WrapResult;
use crate::infra::WrapResult;

pub fn case_unit(type_annot: &Type) -> EvalRet {
Expr::Unit(type_annot.clone()).wrap_ok()
Expand All @@ -14,8 +14,8 @@ mod test {
use crate::eval::eval_expr::eval_expr;
use crate::eval::namely_type;
use crate::eval::Expr;
use crate::infra::rc::RcAnyExt;
use crate::infra::result::WrapResult;
use crate::infra::RcAnyExt;
use crate::infra::WrapResult;

// (): Unit
#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/approx_pi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/expt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/fib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
2 changes: 1 addition & 1 deletion src/eval/eval_expr/test/pi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eval::env::ExprEnv;
use crate::eval::env::TypeEnv;
use crate::eval::eval_expr::eval_expr;
use crate::eval::std::std_code;
use crate::infra::rc::RcAnyExt;
use crate::infra::RcAnyExt;

fn gen_env<'t>() -> (TypeEnv<'t>, Rc<ExprEnv>) {
let seq = std_code().to_owned() +
Expand Down
Loading

0 comments on commit de0e0a3

Please sign in to comment.