Skip to content

Commit

Permalink
Merge branch 'main' of https://gitlab.com/mech-lang/mech
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontella committed Jul 29, 2024
2 parents 30614a9 + 3b00121 commit 604f370
Show file tree
Hide file tree
Showing 15 changed files with 1,600 additions and 2,031 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech"
version = "0.2.3"
version = "0.2.4"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "Toolchain for the Mech programming language."
documentation = "https://mech-lang.org/docs"
Expand All @@ -18,8 +18,8 @@ gitlab = { repository = "mech-lang/mech", branch = "main" }
maintenance = { status = "actively-developed" }

[dependencies]
mech-core = "0.2.3"
mech-syntax = "0.2.3"
mech-core = "0.2.4"
mech-syntax = "0.2.4"
#mech-program = "0.2.2"
#mech-utilities = "0.2.2"

Expand Down
2 changes: 1 addition & 1 deletion src/bin/mech.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use serde_json;


fn main() -> Result<(), MechError> {
let version = "0.2.3";
let version = "0.2.4";
let text_logo = r#"
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │
Expand Down
2 changes: 1 addition & 1 deletion src/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech-core"
version = "0.2.3"
version = "0.2.4"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "The Mech language runtime."
documentation = "http://docs.mech-lang.org"
Expand Down
4 changes: 2 additions & 2 deletions src/syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech-syntax"
version = "0.2.3"
version = "0.2.4"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "A toolchain for compiling textual syntax into Mech blocks."
documentation = "http://docs.mech-lang.org"
Expand All @@ -21,7 +21,7 @@ default = []
no-std = ["mech-core/no-std", "rlibc"]

[dependencies]
mech-core = "0.2.3"
mech-core = "0.2.4"

hashbrown = "0.14.5"
lazy_static = "1.4.0"
Expand Down
5 changes: 0 additions & 5 deletions src/syntax/benches/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ use hashbrown::{HashMap, HashSet};

use std::collections::VecDeque;
use std::thread;
use mech_core::*;
use mech_core::function::table;

use std::fmt::*;
use std::ops::*;

use mech_syntax::parser;
use mech_syntax::ast::Ast;
use mech_syntax::compiler::Compiler;
use mech_core::*;
use mech_syntax::parser;
//use mech_syntax::analyzer::*;
Expand Down
26 changes: 15 additions & 11 deletions src/syntax/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,23 +346,27 @@ fn subscript(sbscrpt: &Subscript, val: &Value, plan: Plan, symbols: SymbolTableR
_ => todo!(),
}
},
Subscript::Range(x) => todo!(),
Subscript::Range(rng) => {
let result = range(rng,plan.clone(), symbols.clone(), functions.clone())?;
match result.as_vecusize() {
Some(v) => Ok(v.to_value()),
None => Err(MechError{tokens: vec![], msg: file!().to_string(), id: line!(), kind: MechErrorKind::UnhandledIndexKind}),
}
},
Subscript::Swizzle(x) => todo!(),
Subscript::Formula(fctr) => {return factor(fctr,plan.clone(), symbols.clone(), functions.clone());},
Subscript::Formula(fctr) => {
let result = factor(fctr,plan.clone(), symbols.clone(), functions.clone())?;
result.as_index()
},
Subscript::Bracket(subs) => {
let mut resolved_subs = vec![];
for s in subs {
let result = subscript(&s, val, plan.clone(), symbols.clone(), functions.clone())?;
match result.as_index() {
Some(ix) => resolved_subs.push(ix),
None => { return Err(MechError{tokens: vec![], msg: file!().to_string(), id: line!(), kind: MechErrorKind::UnhandledIndexKind});}
}
resolved_subs.push(result);
}
let sub_value = match resolved_subs.len() {
1 => resolved_subs[0].clone(),
x => resolved_subs.iter().map(|s| s.as_usize().unwrap()).collect::<Vec<usize>>().to_value(),
};
let new_fxn = MatrixAccess{}.compile(&vec![val.clone(),sub_value])?;
let mut fxn_input = vec![val.clone()];
fxn_input.append(&mut resolved_subs);
let new_fxn = MatrixAccess{}.compile(&fxn_input)?;
new_fxn.solve();
let res = new_fxn.out();
let mut plan_brrw = plan.borrow_mut();
Expand Down
371 changes: 187 additions & 184 deletions src/syntax/src/matrix.rs

Large diffs are not rendered by default.

Loading

0 comments on commit 604f370

Please sign in to comment.