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 Sep 9, 2024
2 parents 6059320 + cdf7cbd commit d7ffa62
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 50 deletions.
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech"
version = "0.2.9"
version = "0.2.10"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "Mech is a reactive programming language for building robots, games, and animations."
documentation = "https://mech-lang.org/docs"
Expand All @@ -18,20 +18,20 @@ gitlab = { repository = "mech-lang/mech", branch = "main" }
maintenance = { status = "actively-developed" }

[dependencies]
mech-core = "0.2.9"
mech-syntax = "0.2.9"
mech-core = "0.2.10"
mech-syntax = "0.2.10"
#mech-program = "0.2.2"
#mech-utilities = "0.2.2"

clap = {version = "4.5.16", features = ["cargo"]}
clap = {version = "4.5.17", features = ["cargo"]}
colored = "2.1.0"
#nom = "7.1.3"
#hashbrown = "0.14.5"
#reqwest = {version = "0.12.4", features = ["blocking"]}
bincode = "1.3.3"
serde = "1.0.209"
serde_derive = "1.0.209"
serde_json = "1.0.127"
serde = "1.0.210"
serde_derive = "1.0.210"
serde_json = "1.0.128"
crossbeam-channel = "0.5.13"
#seahash = "4.1.0"
crossterm = "0.28.1"
Expand Down Expand Up @@ -69,7 +69,7 @@ mech-utilities = { path = 'src/utilities'}
mech-wasm = { path = 'src/wasm'}

[patch.'https://gitlab.com/mech-lang/core']
mech-core = { path = 'src/core', version = '0.2.9' }
mech-core = { path = 'src/core', version = '0.2.10' }

[patch.'https://gitlab.com/mech-lang/syntax']
mech-syntax = { path = 'src/syntax', version = '0.2.9' }
mech-syntax = { path = 'src/syntax', version = '0.2.10' }
41 changes: 22 additions & 19 deletions ROADMAP.mec
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Mech Project Roadmap
===============================================================================

1. Project Status
-------------------------------------------------------------------------------

(a) Stage 1 - Alpha v0.0.1 - v0.0.6

Conception: started 2014
Expand All @@ -19,13 +22,16 @@ Currently: v0.2.7 (2024)

Target release date: ???

Version 0.3.0 (Spring 2025)
2. Nearterm Goals
-------------------------------------------------------------------------------

Version 0.3.0 (Spring 2025) ---------------------------------------------------

- [ ] Dec64
- [ ] Currency
- [ ] Autograd syntax
- [ ] History syntax
- [ ] Imaginary Numbers
- [ ] Database redo
- [ ] ACID
- [ ] Persistence
Expand Down Expand Up @@ -64,9 +70,15 @@ Version 0.3.0 (Spring 2025)
- State machines
- [ ] Specification
- [ ] Definition
- [ ] Split
- [ ] Flatten
- [ ] Solve linear system
- [ ] FSM Pipe
- [ ] Tutorials
- [ ] How-Tos
- [ ] Mech for X

Version 0.2.0 (Fall 2024)
-------------------------------------------------------------------------------
Version 0.2.0 (Fall 2024) ----------------------------------------------------

Current work is focused on reimplementing the core of the Mech language to
reorient programs around state machines. Version 0.2 will be focused on data
Expand All @@ -77,10 +89,8 @@ reshaping it for use in program logic.
- New Literals
- [ ] Enums
- [x] Atoms
- [ ] Kind definitions
- [x] Specifying units
- [ ] Scientific notation
- [ ] Imaginary Numbers
- [x] Scientific notation
- Table redo
- [x] Different kinds: Table, Matrix, Record, Set, Tuple
- [x] Simplify indexing
Expand Down Expand Up @@ -118,36 +128,31 @@ reshaping it for use in program logic.
- [x] Struct
- [x] Literal
- [x] Function call
- [ ] FSM Pipe
- Statement
- [x] VarDefine
- [ ] VarAssign
- [ ] Kind Define
- [ ] Enum Define
- [ ] FSM Declaration
- [ ] Split
- [ ] Flatten
- Matrix
- [x] Multiply
- [x] Transpose
- [ ] Solve linear system
- [ ] Cross
- [ ] Dot
- Docs
- [ ] Language Spec
- [x] Learn Mech in 15 Minutes
- [ ] Tutorials
- [ ] How-Tos
- [ ] Mech for X
- Website
- [ ] Homepage
- [ ] Blog
- [ ] Docs
- [ ] Try

Version 0.1.1 (Spring 2023)

3. Project History
-------------------------------------------------------------------------------

Version 0.1.1 (Spring 2023) ---------------------------------------------------

- Core
- [x] Automatic differentiation
- [x] Capability system
Expand All @@ -172,8 +177,7 @@ Version 0.1.1 (Spring 2023)
- [x] More gui
- [x] ai

Version 0.1.0 (December 2022)
-------------------------------------------------------------------------------
Version 0.1.0 (December 2022) -------------------------------------------------

- [x] User defined functions
- [x] Errors
Expand All @@ -190,8 +194,7 @@ Version 0.1.0 (December 2022)
- [x] Matrix
- [x] GUI

Version 0.0.6 Alpha (unreleased)
-------------------------------------------------------------------------------
Version 0.0.6 Alpha (unreleased) ----------------------------------------------

- [x] Testing
- Machines
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated from c5f061 to 807611
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.9";
let version = "0.2.10";
let text_logo = r#"
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │
Expand Down
8 changes: 4 additions & 4 deletions 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.9"
version = "0.2.10"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "The Mech language runtime."
documentation = "http://docs.mech-lang.org"
Expand All @@ -25,12 +25,12 @@ wasm = ["web-sys", "wasm-bindgen"]

[dependencies]
hashbrown = "0.14.5"
serde = {version = "1.0.209", default-features = false, features = ["alloc"] }
serde_derive = "1.0.209"
serde = {version = "1.0.210", default-features = false, features = ["alloc"] }
serde_derive = "1.0.210"
rlibc = { version = "=1.0", optional = true }
lazy_static = "1.5.0"
seahash = "4.1.0"
indexmap = "2.4.0"
indexmap = "2.5.0"
rayon = {version = "1.10.0", optional = true}
time = {version = "0.3.36", optional = true}
ed25519-dalek = {version = "2.1.1", default-features = false, features = ["rand_core"]}
Expand Down
43 changes: 38 additions & 5 deletions src/core/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,23 @@ fn statement(stmt: &Statement, plan: Plan, symbols: SymbolTableRef, functions: F
match stmt {
Statement::VariableDefine(var_def) => variable_define(&var_def, plan.clone(), symbols.clone(), functions.clone()),
Statement::VariableAssign(_) => todo!(),
Statement::KindDefine(_) => todo!(),
Statement::KindDefine(knd_def) => kind_define(&knd_def, plan.clone(), symbols.clone(), functions.clone()),
Statement::EnumDefine(_) => todo!(),
Statement::FsmDeclare(_) => todo!(),
Statement::SplitTable => todo!(),
Statement::FlattenTable => todo!(),
}
}

fn kind_define(knd_def: &KindDefine, plan: Plan, symbols: SymbolTableRef, functions: FunctionsRef) -> MResult<Value> {
let id = knd_def.name.hash();
let kind = kind_annotation(&knd_def.kind.kind, functions.clone())?;
let value_kind = kind.to_value_kind(functions.clone())?;
let mut fxns_brrw = functions.borrow_mut();
fxns_brrw.kinds.insert(id, value_kind.clone());
Ok(Value::Kind(value_kind))
}

fn variable_define(var_def: &VariableDefine, plan: Plan, symbols: SymbolTableRef, functions: FunctionsRef) -> MResult<Value> {
let id = var_def.var.name.hash();
let mut result = expression(&var_def.expression, plan.clone(), symbols.clone(), functions.clone())?;
Expand Down Expand Up @@ -854,15 +863,39 @@ fn real(rl: &RealNumber) -> Value {
RealNumber::Negated(num) => todo!(),
RealNumber::Integer(num) => integer(num),
RealNumber::Float(num) => float(num),
RealNumber::Decimal(num) => todo!(),
RealNumber::Hexadecimal(num) => todo!(),
RealNumber::Octal(num) => todo!(),
RealNumber::Binary(num) => todo!(),
RealNumber::Decimal(num) => dec(num),
RealNumber::Hexadecimal(num) => hex(num),
RealNumber::Octal(num) => oct(num),
RealNumber::Binary(num) => binary(num),
RealNumber::Scientific(num) => scientific(num),
RealNumber::Rational(num) => todo!(),
}
}

fn dec(bnry: &Token) -> Value {
let binary_str: String = bnry.chars.iter().collect();
let num = i64::from_str_radix(&binary_str, 10).unwrap();
Value::I64(new_ref(num))
}

fn binary(bnry: &Token) -> Value {
let binary_str: String = bnry.chars.iter().collect();
let num = i64::from_str_radix(&binary_str, 2).unwrap();
Value::I64(new_ref(num))
}

fn oct(octl: &Token) -> Value {
let hex_str: String = octl.chars.iter().collect();
let num = i64::from_str_radix(&hex_str, 8).unwrap();
Value::I64(new_ref(num))
}

fn hex(hxdcml: &Token) -> Value {
let hex_str: String = hxdcml.chars.iter().collect();
let num = i64::from_str_radix(&hex_str, 16).unwrap();
Value::I64(new_ref(num))
}

fn scientific(sci: &(Base,Exponent)) -> Value {
let (base,exp): &(Base,Exponent) = sci;
let (whole,part): &(Whole,Part) = base;
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ pub struct EnumVariant {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct KindDefine {
pub name: Identifier,
pub definition: KindAnnotation,
pub kind: KindAnnotation,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/core/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ impl Value {
Value::Empty => builder.push_record(vec!["_"]),
Value::IndexAll => builder.push_record(vec![":"]),
Value::Id(x) => builder.push_record(vec![format!("{:?}",humanize(x))]),
_ => unreachable!(),
Value::Kind(x) => builder.push_record(vec![format!("{:?}",x)]),

};
let mut table = builder.build();
table.with(Style::modern());
Expand Down
10 changes: 5 additions & 5 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.9"
version = "0.2.10"
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,19 +21,19 @@ default = []
no-std = ["mech-core/no-std", "rlibc"]

[dependencies]
mech-core = "0.2.9"
mech-core = "0.2.10"

hashbrown = "0.14.5"
lazy_static = "1.5.0"
nom = "7.1.3"
nom-unicode = "0.3.0"
unicode-segmentation = "1.11.0"
rlibc = { version = "=1.0", optional = true }
serde = "1.0.209"
serde_derive = "1.0.209"
serde = "1.0.210"
serde_derive = "1.0.210"
colored = "2.1.0"
nalgebra = "0.33.0"
indexmap = "2.4.0"
indexmap = "2.5.0"
tabled = "0.16.0"
libm = "0.2.8"
simba = "0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/src/statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub fn kind_define(input: ParseString) -> ParseResult<KindDefine> {
let (input, _) = right_angle(input)?;
let (input, _) = define_operator(input)?;
let (input, knd) = kind_annotation(input)?;
Ok((input, KindDefine{name,definition: knd}))
Ok((input, KindDefine{name,kind:knd}))
}


Expand Down
8 changes: 8 additions & 0 deletions src/syntax/tests/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ use na::{Vector3, DVector, RowDVector, Matrix1, Matrix3, Matrix4, RowVector3, Ro

test_interpreter!(interpret_literal_integer, "123", Value::I64(new_ref(123)));
test_interpreter!(interpret_literal_sci, "1.23e2", Value::F64(new_ref(F64::new(123.0))));
test_interpreter!(interpret_literal_bin, "0b10101", Value::I64(new_ref(21)));
test_interpreter!(interpret_literal_hex, "0x123abc", Value::I64(new_ref(1194684)));
test_interpreter!(interpret_literal_oct, "0o1234", Value::I64(new_ref(668)));
test_interpreter!(interpret_literal_dec, "0d1234", Value::I64(new_ref(1234)));

test_interpreter!(interpret_literal_float, "1.23", Value::F64(new_ref(F64::new(1.23))));
test_interpreter!(interpret_literal_string, r#""Hello""#, Value::String("Hello".to_string()));
test_interpreter!(interpret_literal_true, "true", Value::Bool(new_ref(true)));
Expand All @@ -59,6 +64,9 @@ test_interpreter!(interpret_kind_lhs_define_overflow, "x<u8> := 256", Value::U8(
test_interpreter!(interpret_kind_convert_twice, "x<u64> := 1; y<i8> := x", Value::I8(new_ref(1)));
test_interpreter!(interpret_kind_convert_float, "x<f32> := 123;", Value::F32(new_ref(F32::new(123.0))));

test_interpreter!(interpret_kind_define, "<foo> := <i64>; x<foo> := 123", Value::I64(new_ref(123)));


test_interpreter!(interpret_formula_math_neg, "-1", Value::I64(new_ref(-1)));
test_interpreter!(interpret_formula_math_multiple_terms, "1 + 2 + 3", Value::I64(new_ref(6)));
test_interpreter!(interpret_formula_comparison_bool, "true == false", Value::Bool(new_ref(false)));
Expand Down
6 changes: 3 additions & 3 deletions src/syntax/tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ test_parser!(parse_statement_variable_define_annotated_tuple_rhs, "z := (10<u8>,

test_parser!(parse_statement_variable_assign, "a = 2", 5448552719387223);
test_parser!(parse_statement_variable_assign_slice, "a[1] = 2", 20762289900010478);
test_parser!(parse_statement_kind_define, "<pos> := <(u8,u8,u8)>", 23009507256904188);
test_parser!(parse_statement_kind_define_size, "<foo> := <([u8]:1,2, [u8]:3,3)>", 7698832452691191);
test_parser!(parse_statement_kind_define_size_hex, "<bar> := <[foo]:0x01, 0xFF>", 6442842300718590);
test_parser!(parse_statement_kind_define, "<pos> := <(u8,u8,u8)>", 19272007189561377);
test_parser!(parse_statement_kind_define_size, "<foo> := <([u8]:1,2, [u8]:3,3)>", 19568235100036623);
test_parser!(parse_statement_kind_define_size_hex, "<bar> := <[foo]:0x01, 0xFF>", 52794480162632018);

test_parser!(parse_statement_enum_define, "<my-type> := A | B", 64572902068503820);
test_parser!(parse_statement_enum_define_typed, "<my-type> := A(<u8>) | B", 62980205579073513);
Expand Down

0 comments on commit d7ffa62

Please sign in to comment.