Skip to content

Commit 998cd1c

Browse files
committed
Merge branch 'v0.2-beta' into 'main'
V0.2.5 beta See merge request mech-lang/mech!57
2 parents 3b00121 + e6d14f4 commit 998cd1c

File tree

9 files changed

+436
-58
lines changed

9 files changed

+436
-58
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mech"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "Toolchain for the Mech programming language."
66
documentation = "https://mech-lang.org/docs"
@@ -18,8 +18,8 @@ gitlab = { repository = "mech-lang/mech", branch = "main" }
1818
maintenance = { status = "actively-developed" }
1919

2020
[dependencies]
21-
mech-core = "0.2.4"
22-
mech-syntax = "0.2.4"
21+
mech-core = "0.2.5"
22+
mech-syntax = "0.2.5"
2323
#mech-program = "0.2.2"
2424
#mech-utilities = "0.2.2"
2525

src/bin/mech.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use serde_json;
2525

2626

2727
fn main() -> Result<(), MechError> {
28-
let version = "0.2.4";
28+
let version = "0.2.5";
2929
let text_logo = r#"
3030
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
3131
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │
@@ -139,11 +139,17 @@ fn main() -> Result<(), MechError> {
139139
io::stdin().read_line(&mut input).unwrap();
140140
match parser::parse(&input) {
141141
Ok(tree) => {
142+
let now = Instant::now();
142143
let result = intrp.interpret(&tree);
144+
let elapsed_time = now.elapsed();
145+
let cycle_duration = elapsed_time.as_nanos() as f64;
146+
143147
match result {
144148
Ok(r) => println!("{}", r.pretty_print()),
145149
Err(err) => println!("{:?}", err),
146150
}
151+
println!("{:0.2?} ns", cycle_duration / 1000000.0);
152+
147153
}
148154
Err(err) => {
149155
if let MechErrorKind::ParserError(report, _) = err.kind {

src/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mech-core"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "The Mech language runtime."
66
documentation = "http://docs.mech-lang.org"

src/syntax/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mech-syntax"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "A toolchain for compiling textual syntax into Mech blocks."
66
documentation = "http://docs.mech-lang.org"
@@ -21,7 +21,7 @@ default = []
2121
no-std = ["mech-core/no-std", "rlibc"]
2222

2323
[dependencies]
24-
mech-core = "0.2.4"
24+
mech-core = "0.2.5"
2525

2626
hashbrown = "0.14.5"
2727
lazy_static = "1.4.0"

src/syntax/src/interpreter.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,36 @@ fn subscript(sbscrpt: &Subscript, val: &Value, plan: Plan, symbols: SymbolTableR
359359
result.as_index()
360360
},
361361
Subscript::Bracket(subs) => {
362+
let mut fxn_input = vec![val.clone()];
363+
/*match &subs[..] {
364+
[Subscript::Formula(ix)] => {
365+
let result = factor(&ix, plan.clone(), symbols.clone(), functions.clone())?;
366+
fxn_input.push(result.as_index()?);
367+
let new_fxn = MatrixAccessFormula{}.compile(&fxn_input)?;
368+
new_fxn.solve();
369+
let res = new_fxn.out();
370+
let mut plan_brrw = plan.borrow_mut();
371+
plan_brrw.push(new_fxn);
372+
return Ok(res);
373+
},
374+
[Subscript::Range(ix)] => (),
375+
[Subscript::All] => (),
376+
[Subscript::All,Subscript::All] => (),
377+
[Subscript::Formula(ix1),Subscript::Formula(ix2)] => (),
378+
[Subscript::Range(ix1),Subscript::Range(ix2)] => (),
379+
[Subscript::All,Subscript::Formula(ix2)] => (),
380+
[Subscript::Formula(ix1),Subscript::All] => (),
381+
[Subscript::Range(ix1),Subscript::Formula(ix2)] => (),
382+
[Subscript::Formula(ix1),Subscript::Range(ix2)] => (),
383+
[Subscript::All,Subscript::Range(ix2)] => (),
384+
[Subscript::Range(ix1),Subscript::All] => (),
385+
_ => unreachable!()
386+
}*/
362387
let mut resolved_subs = vec![];
363388
for s in subs {
364389
let result = subscript(&s, val, plan.clone(), symbols.clone(), functions.clone())?;
365390
resolved_subs.push(result);
366391
}
367-
let mut fxn_input = vec![val.clone()];
368392
fxn_input.append(&mut resolved_subs);
369393
let new_fxn = MatrixAccess{}.compile(&fxn_input)?;
370394
new_fxn.solve();
@@ -374,7 +398,7 @@ fn subscript(sbscrpt: &Subscript, val: &Value, plan: Plan, symbols: SymbolTableR
374398
Ok(res)
375399
},
376400
Subscript::Brace(x) => todo!(),
377-
Subscript::All => todo!(),
401+
Subscript::All => Ok(Value::IndexAll),
378402
}
379403
}
380404

src/syntax/src/matrix.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ macro_rules! impl_to_matrix {
2222
match (rows,cols) {
2323
(1,1) => Matrix::Matrix1(new_ref(Matrix1::from_element(elements[0].clone()))),
2424
(2,2) => Matrix::Matrix2(new_ref(Matrix2::from_vec(elements))),
25-
(3,4) => Matrix::Matrix3(new_ref(Matrix3::from_vec(elements))),
25+
(3,3) => Matrix::Matrix3(new_ref(Matrix3::from_vec(elements))),
2626
(4,2) => Matrix::Matrix4(new_ref(Matrix4::from_vec(elements))),
2727
(2,3) => Matrix::Matrix2x3(new_ref(Matrix2x3::from_vec(elements))),
2828
(3,2) => Matrix::Matrix3x2(new_ref(Matrix3x2::from_vec(elements))),
@@ -36,7 +36,8 @@ macro_rules! impl_to_matrix {
3636
(m,1) => Matrix::DVector(new_ref(DVector::from_vec(elements))),
3737
(m,n) => Matrix::DMatrix(new_ref(DMatrix::from_vec(m,n,elements))),
3838
}}}};}
39-
39+
40+
impl_to_matrix!(usize);
4041
impl_to_matrix!(bool);
4142
impl_to_matrix!(u8);
4243
impl_to_matrix!(u16);

0 commit comments

Comments
 (0)