Skip to content

Commit

Permalink
bump Yoorkin/ArgParser to 0.1.7 (#25)
Browse files Browse the repository at this point in the history
* bump Yoorkin/ArgParser to 0.1.7

* moon info
  • Loading branch information
Young-Flash authored Jan 2, 2025
2 parents 3285ef9 + 7b65e38 commit 820584b
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 148 deletions.
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"deps": {
"moonbitlang/x": "0.4.15",
"Yoorkin/ArgParser": "0.1.6"
"Yoorkin/ArgParser": "0.1.7"
},
"readme": "README.md",
"license": "BSD-3-Clause",
Expand Down
8 changes: 6 additions & 2 deletions src/bin/bin.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package moonbitlang/minimbt/bin
// Values

// Types and methods
type CompileStatus

type Stages
impl Compare for Stages
impl Eq for Stages
impl Show for Stages

// Type aliases

// Traits

// Extension Methods

76 changes: 36 additions & 40 deletions src/closure/closure.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ alias @moonbitlang/minimbt/knf as @knf
fn knf_program_to_closure(@knf.Knf, Map[String, @minimbt.Type]) -> Program

// Types and methods
pub struct Closure {
pub name : Label
pub actual_free_vars : Array[@minimbt.Name]
pub(all) struct Closure {
name : Label
actual_free_vars : Array[@minimbt.Name]
}
impl Closure {
to_string(Self) -> String
from_json(Json) -> Self!
to_json(Self) -> Json
}
impl Show for Closure

pub enum Expr {
pub(all) enum Expr {
Unit
Int(Int)
Double(Double)
Expand All @@ -31,39 +33,42 @@ pub enum Expr {
FDiv(@minimbt.Name, @minimbt.Name)
IfEq(@minimbt.Name, @minimbt.Name, Expr, Expr)
IfLe(@minimbt.Name, @minimbt.Name, Expr, Expr)
Let(Tuple[@minimbt.Name, LowType], Expr, Expr)
Let((@minimbt.Name, LowType), Expr, Expr)
Var(@minimbt.Name)
MakeClosure(Tuple[@minimbt.Name, LowType], Closure, Expr)
MakeClosure((@minimbt.Name, LowType), Closure, Expr)
CallClosure(@minimbt.Name, Array[@minimbt.Name])
CallDirect(Label, Array[@minimbt.Name])
MakeTuple(Array[@minimbt.Name])
LetTuple(Array[Tuple[@minimbt.Name, LowType]], @minimbt.Name, Expr)
LetTuple(Array[(@minimbt.Name, LowType)], @minimbt.Name, Expr)
ArrayGet(@minimbt.Name, @minimbt.Name)
ArrayPut(@minimbt.Name, @minimbt.Name, @minimbt.Name)
ExternalArray(Label)
}
impl Expr {
to_string(Self) -> String
from_json(Json) -> Self!
to_json(Self) -> Json
}
impl Show for Expr

pub struct FuncDef {
pub name : Label
pub old_name : @minimbt.Name
pub ty : LowType
pub args : Array[Tuple[@minimbt.Name, LowType]]
pub formal_free_vars : Array[Tuple[@minimbt.Name, LowType]]
pub body : Expr
pub(all) struct FuncDef {
name : Label
old_name : @minimbt.Name
is_closure : Bool
ty : LowType
args : Array[(@minimbt.Name, LowType)]
formal_free_vars : Array[(@minimbt.Name, LowType)]
body : Expr
}
impl FuncDef {
to_string(Self) -> String
from_json(Json) -> Self!
to_json(Self) -> Json
}
impl Show for FuncDef

pub type Label String
impl Label {
to_string(Self) -> String
}
pub(all) type Label String
impl Show for Label

pub enum LowType {
pub(all) enum LowType {
Unit
Bool
Int
Expand All @@ -75,19 +80,23 @@ pub enum LowType {
Ptr
}
impl LowType {
from_json(Json) -> Self!
is_float_like(Self) -> Bool
is_ptr_like(Self) -> Bool
size_of(Self, Int) -> Int
to_string(Self) -> String
to_json(Self) -> Json
}
impl Show for LowType

pub struct Program {
pub fundefs : Array[FuncDef]
pub body : Expr
pub(all) struct Program {
fundefs : Array[FuncDef]
body : Expr
}
impl Program {
to_string(Self) -> String
from_json(Json) -> Self!
to_json(Self) -> Json
}
impl Show for Program

// Type aliases
pub typealias LocalEnv = @moonbitlang/core/immut/hashmap.T[@minimbt.Name, LowType]
Expand All @@ -98,16 +107,3 @@ pub typealias Type = @minimbt.Type

// Traits

// Extension Methods
impl Show for Closure

impl Show for Expr

impl Show for FuncDef

impl Show for Label

impl Show for LowType

impl Show for Program

39 changes: 39 additions & 0 deletions src/closure_eval/closure_eval.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package moonbitlang/minimbt/closure_eval

alias @moonbitlang/core/immut/hashmap as @hashmap
alias @moonbitlang/minimbt as @minimbt
alias @moonbitlang/minimbt/closure as @closure

// Values

// Types and methods
type ClosureInterpreter
impl ClosureInterpreter {
add_extern_fn(Self, String, (Array[Value]) -> Value) -> Unit
eval(Self, @hashmap.T[@minimbt.Name, Value], @closure.Expr) -> Value!Failure
eval_fn(Self, @closure.FuncDef, Array[Value], Array[Value]) -> Value!Failure
eval_full(Self, @closure.Program) -> Value!Failure
new() -> Self
}

pub(all) enum Value {
Unit
Int(Int)
Double(Double)
Tuple(Array[Value])
Array(Array[Value])
ExternFn(String)
Closure(@closure.FuncDef, Array[Value])
}
impl Value {
op_equal(Self, Self) -> Bool
}
impl Show for Value

// Type aliases
pub typealias InterpreterLocalVars = @hashmap.T[@minimbt.Name, Value]

pub typealias Name = @minimbt.Name

// Traits

38 changes: 19 additions & 19 deletions src/knf/knf.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ alias @moonbitlang/core/immut/hashmap as @hashmap
alias @moonbitlang/minimbt as @minimbt

// Values
fn knf_max_counter(Knf) -> Int

// Types and methods
pub struct FuncDef {
pub name : @minimbt.Name
pub ty : @minimbt.Type
pub args : Array[Tuple[@minimbt.Name, @minimbt.Type]]
pub body : Knf
pub(all) struct FuncDef {
name : @minimbt.Name
ty : @minimbt.Type
args : Array[(@minimbt.Name, @minimbt.Type)]
body : Knf
}
impl FuncDef {
op_equal(Self, Self) -> Bool
to_string(Self) -> String
from_json(Json) -> Self!
to_json(Self) -> Json
}
impl Eq for FuncDef
impl Show for FuncDef

pub enum Knf {
pub(all) enum Knf {
Unit
Int(Int)
Double(Double)
Expand All @@ -33,32 +36,36 @@ pub enum Knf {
FDiv(@minimbt.Name, @minimbt.Name)
IfEq(@minimbt.Name, @minimbt.Name, Knf, Knf)
IfLe(@minimbt.Name, @minimbt.Name, Knf, Knf)
Let(Tuple[@minimbt.Name, @minimbt.Type], Knf, Knf)
Let((@minimbt.Name, @minimbt.Type), Knf, Knf)
Var(@minimbt.Name)
LetRec(FuncDef, Knf)
Apply(@minimbt.Name, Array[@minimbt.Name])
Tuple(Array[@minimbt.Name])
LetTuple(Array[Tuple[@minimbt.Name, @minimbt.Type]], @minimbt.Name, Knf)
LetTuple(Array[(@minimbt.Name, @minimbt.Type)], @minimbt.Name, Knf)
Get(@minimbt.Name, @minimbt.Name)
Put(@minimbt.Name, @minimbt.Name, @minimbt.Name)
ExternalArray(@minimbt.Name)
ExternalFunctionApplication(String, Array[@minimbt.Name])
}
impl Knf {
op_equal(Self, Self) -> Bool
from_json(Json) -> Self!
to_json(Self) -> Json
to_pretty_print(Self) -> PrettyKnf
to_string(Self) -> String
}
impl Eq for Knf
impl Show for Knf

type KnfEnv
impl KnfEnv {
init_counter_from_existing(Self, Knf) -> Unit
new(@hashmap.T[String, @minimbt.Type]) -> Self
opt_pass(Self, Knf) -> Knf
syntax_preprocess(Self, @minimbt.Syntax) -> @minimbt.Syntax
to_knf(Self, @minimbt.Syntax) -> Knf
}

type PrettyKnf
impl Show for PrettyKnf

// Type aliases
pub typealias LocalEnv = @hashmap.T[String, @minimbt.Type]
Expand All @@ -69,10 +76,3 @@ pub typealias Type = @minimbt.Type

// Traits

// Extension Methods
impl Show for FuncDef

impl Show for Knf

impl Show for PrettyKnf

7 changes: 2 additions & 5 deletions src/knf_eval/knf_eval.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl KnfInterpreter {
new() -> Self
}

pub enum Value {
pub(all) enum Value {
Unit
Int(Int)
Double(Double)
Expand All @@ -26,8 +26,8 @@ pub enum Value {
}
impl Value {
op_equal(Self, Self) -> Bool
to_string(Self) -> String
}
impl Show for Value

// Type aliases
pub typealias InterpreterLocalVars = @hashmap.T[@minimbt.Name, Value]
Expand All @@ -36,6 +36,3 @@ pub typealias Name = @minimbt.Name

// Traits

// Extension Methods
impl Show for Value

2 changes: 0 additions & 2 deletions src/lex/lex.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ package moonbitlang/minimbt/lex

// Traits

// Extension Methods

Loading

0 comments on commit 820584b

Please sign in to comment.