Skip to content

Commit 73404e8

Browse files
committed
Merge branch 'main' of https://gitlab.com/mech-lang/mech
2 parents d7ffa62 + f26a724 commit 73404e8

File tree

15 files changed

+129
-58
lines changed

15 files changed

+129
-58
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mech"
3-
version = "0.2.10"
3+
version = "0.2.11"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "Mech is a reactive programming language for building robots, games, and animations."
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.10"
22-
mech-syntax = "0.2.10"
21+
mech-core = "0.2.11"
22+
mech-syntax = "0.2.11"
2323
#mech-program = "0.2.2"
2424
#mech-utilities = "0.2.2"
2525

@@ -69,7 +69,7 @@ mech-utilities = { path = 'src/utilities'}
6969
mech-wasm = { path = 'src/wasm'}
7070

7171
[patch.'https://gitlab.com/mech-lang/core']
72-
mech-core = { path = 'src/core', version = '0.2.10' }
72+
mech-core = { path = 'src/core', version = '0.2.11' }
7373

7474
[patch.'https://gitlab.com/mech-lang/syntax']
75-
mech-syntax = { path = 'src/syntax', version = '0.2.10' }
75+
mech-syntax = { path = 'src/syntax', version = '0.2.11' }

README.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
11
<p align="center">
2-
<img width="500px" src="https://mech-lang.org/img/logo.png">
2+
<img width="500px" src="https://mech-lang.org/img/logo.png" alt="Mech Logo">
33
</p>
44

5-
Mech is a language for developing **data-driven**, **reactive** systems like animations, games, and robots. It makes **composing**, **transforming**, and **distributing** data easy, allowing you to focus on the essential complexity of your project.
5+
**Mech** is a language designed for building **data-driven** and **reactive** systems like robots, games, user interfaces, and more. It simplifies **composing**, **transforming**, and **distributing** data, so you can focus on the core complexities of your project.
66

7-
[Try](https://mech-lang.org/try/) Mech online in your browser, or follow our progress on our [blog](https://mech-lang.org/blog/).
7+
[Try Mech](https://mech-lang.org/try/) online in your browser or stay updated through our [blog](https://mech-lang.org/blog/).
88

9-
## Documentation
9+
## 📚 Documentation
1010

11-
If this is your first time with Mech, read [Learn Mech in Fifteen Minutes](https://gitlab.com/mech-lang/docs/-/raw/v0.2-beta/III.guides/MechFifteen.mec).
11+
New to Mech? Start with [Learn Mech in Fifteen Minutes](https://gitlab.com/mech-lang/docs/-/raw/v0.2-beta/III.guides/MechFifteen.mec).
1212

13-
Documentation is hosted online at [mech-lang.org](https://mech-lang.org/docs), and is open sourced on [GitHub](http://github.com/mech-lang/docs).
13+
Comprehensive documentation is available at [mech-lang.org](https://mech-lang.org/docs) and open-sourced on [GitHub](http://github.com/mech-lang/docs).
1414

15-
## Installation
15+
## 📂 Download and Install
1616

17-
### Binary
17+
### 💾 From Binary
1818

19-
You can download the latest release for your platform [here](https://github.com/mech-lang/mech/releases).
19+
Download the latest release for your platform [here](https://github.com/mech-lang/mech/releases).
2020

21-
### Source
21+
### 🔨 From Source
2222

23-
You will need to install [Rust](https://www.rust-lang.org/learn/get-started) on a recent nightly release. Follow these instructions to build the Mech language toolchain, which is packaged in a single executable called "mech":
23+
To build Mech from source, you’ll need to install [Rust](https://www.rust-lang.org/learn/get-started) (nightly version). Follow the instructions below to compile the Mech toolchain, bundled in a single executable called `mech`:
2424

2525
```bash
2626
git clone https://gitlab.com/mech-lang/mech
2727
cd mech
2828
cargo build --bin mech --release
2929
```
3030

31-
## Project Roadmap
31+
## 🚧 Project Roadmap
3232

33-
Mech is undergoing a redesign to incorporate state machines into the language.
33+
Mech is being redesigned to integrate state machines into the language, with development happening in the v0.2-beta branch.
3434

35-
This work is happening in the v0.2-beta branch of the repository.
35+
The v0.2 release is planned for October 2024. For more details, check out the [ROADMAP.mec](ROADMAP.mec).
3636

37-
The current target for the release of v0.2 is October 2024.
37+
## ⚖️ License
3838

39-
See [ROADMAP.mec](ROADMAP.mec) for more.
40-
41-
## License
42-
43-
Apache 2.0
39+
Licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).

ROADMAP.mec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ reshaping it for use in program logic.
131131
- Statement
132132
- [x] VarDefine
133133
- [ ] VarAssign
134-
- [ ] Kind Define
134+
- [x] Kind Define
135135
- [ ] Enum Define
136136
- Matrix
137137
- [x] Multiply

src/bin/mech.rs

Lines changed: 1 addition & 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.10";
28+
let version = "0.2.11";
2929
let text_logo = r#"
3030
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
3131
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │

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.10"
3+
version = "0.2.11"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "The Mech language runtime."
66
documentation = "http://docs.mech-lang.org"

src/core/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
<p align="center">
2-
<img width="400px" src="https://mech-lang.org/img/logo.png">
2+
<img width="500px" src="https://mech-lang.org/img/logo.png">
33
</p>
44

5-
Mech is a language for developing **data-driven**, **reactive** systems like robots, games, and animations. It makes **composing**, **transforming**, and **distributing** data easy, allowing you to focus on the essential complexity of your project.
5+
Mech is a language for developing **data-driven**, **reactive** systems like animations, games, and robots. It makes **composing**, **transforming**, and **distributing** data easy, allowing you to focus on the essential complexity of your project.
66

7-
You can try Mech online at [https://mech-lang.org/try](https://mech-lang.org/try).
8-
9-
Usage and installation instructions can be found in the [documentation](https://mech-lang.org/#/docs/index.mec) or the [main Mech repository](https://github.com/mech-lang/mech).
10-
11-
Be sure to follow our [blog](https://mech-lang.org/blog/)([RSS](https://mech-lang.org/feed.xml))!
7+
[Try](https://mech-lang.org/try/) Mech online in your browser, or follow our progress on our [blog](https://mech-lang.org/blog/).
128

139
# Core
1410

1511
The language runtime. It's a small dataflow engine that accepts transactions of changes, and applies them to a compute network.
1612

1713
## Contents
1814

19-
- **block** - defines a `Block`, which is the ubiquitous unit of code in Mech. A block is comprised of transformations on input tables. These transformations can either modify existing tables or create new tables.
20-
- **table** - defines a `Table`, the core data structure of Mech. A table is a 2D array of values.
21-
- **column** - defines a `Column`, which is a vector of values.
22-
- **value** - defines a `Value`, a unified datatype for Mech. A value can be empty, a boolean, a string, a reference to another table, a number literal.
23-
- **database** - defines a `Database` of tables. Databases accept `Transactions`, which are sets of `Changes` to the database.
24-
- **function** - defines the standard library for Mech, including basic indexing, mathematical, comparison, and logic functions.
25-
- **error** - defines an `MechError`, which holds the information necessary to track and render error messages.
15+
- **interpreter** - The Mech interpreter, which executes Mech bytecode.
16+
- **value** - Defines `Value`, a unified datatype
17+
- **kind** - Defines `Kind`, which is used to annotate the kind of each varible
18+
- **error** - Define `MechError`, an error type that is used throughout the Mech system.
19+
- **functions** - User defined functions
20+
- **matrix** - Mech `Matrix` wraps NDArray for fast matrix computations
21+
- **nodes** - Defines various nodes which comprise the Mech AST.
22+
- **types** - Defines various types used by the Rust implementation of the Mech compiler.
2623

2724
## Project Status
2825

src/core/src/interpreter.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,20 @@ fn statement(stmt: &Statement, plan: Plan, symbols: SymbolTableRef, functions: F
151151
Statement::VariableDefine(var_def) => variable_define(&var_def, plan.clone(), symbols.clone(), functions.clone()),
152152
Statement::VariableAssign(_) => todo!(),
153153
Statement::KindDefine(knd_def) => kind_define(&knd_def, plan.clone(), symbols.clone(), functions.clone()),
154-
Statement::EnumDefine(_) => todo!(),
154+
Statement::EnumDefine(enm_def) => enum_define(&enm_def, plan.clone(), symbols.clone(), functions.clone()),
155155
Statement::FsmDeclare(_) => todo!(),
156156
Statement::SplitTable => todo!(),
157157
Statement::FlattenTable => todo!(),
158158
}
159159
}
160160

161+
fn enum_define(enm_def: &EnumDefine, plan: Plan, symbols: SymbolTableRef, functions: FunctionsRef) -> MResult<Value> {
162+
let id = enm_def.name.hash();
163+
164+
165+
Ok(Value::Empty)
166+
}
167+
161168
fn kind_define(knd_def: &KindDefine, plan: Plan, symbols: SymbolTableRef, functions: FunctionsRef) -> MResult<Value> {
162169
let id = knd_def.name.hash();
163170
let kind = kind_annotation(&knd_def.kind.kind, functions.clone())?;

src/syntax/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-syntax"
3-
version = "0.2.10"
3+
version = "0.2.11"
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,13 +21,13 @@ default = []
2121
no-std = ["mech-core/no-std", "rlibc"]
2222

2323
[dependencies]
24-
mech-core = "0.2.10"
24+
mech-core = "0.2.11"
2525

2626
hashbrown = "0.14.5"
2727
lazy_static = "1.5.0"
2828
nom = "7.1.3"
2929
nom-unicode = "0.3.0"
30-
unicode-segmentation = "1.11.0"
30+
unicode-segmentation = "1.12.0"
3131
rlibc = { version = "=1.0", optional = true }
3232
serde = "1.0.210"
3333
serde_derive = "1.0.210"

src/syntax/src/base.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ leaf!{box_t_top, "┬", TokenKind::BoxDrawing}
7878
leaf!{box_t_bottom, "┴", TokenKind::BoxDrawing}
7979
leaf!{box_vert, "│", TokenKind::BoxDrawing}
8080

81+
// emoji_grapheme := emoji_grapheme_literal ;
8182
pub fn emoji_grapheme(mut input: ParseString) -> ParseResult<String> {
8283
if let Some(matched) = input.consume_emoji() {
8384
Ok((input, matched))
@@ -86,6 +87,7 @@ pub fn emoji_grapheme(mut input: ParseString) -> ParseResult<String> {
8687
}
8788
}
8889

90+
// alpha := alpha_literal ;
8991
pub fn alpha(mut input: ParseString) -> ParseResult<String> {
9092
if let Some(matched) = input.consume_alpha() {
9193
Ok((input, matched))
@@ -94,6 +96,7 @@ pub fn alpha(mut input: ParseString) -> ParseResult<String> {
9496
}
9597
}
9698

99+
// digit := digit_literal ;
97100
pub fn digit(mut input: ParseString) -> ParseResult<String> {
98101
if let Some(matched) = input.consume_digit() {
99102
Ok((input, matched))
@@ -102,6 +105,7 @@ pub fn digit(mut input: ParseString) -> ParseResult<String> {
102105
}
103106
}
104107

108+
// any := any_character ;
105109
pub fn any(mut input: ParseString) -> ParseResult<String> {
106110
if let Some(matched) = input.consume_one() {
107111
Ok((input, matched))
@@ -110,6 +114,7 @@ pub fn any(mut input: ParseString) -> ParseResult<String> {
110114
}
111115
}
112116

117+
// forbidden_emoji := box_drawing | other_forbidden_shapes ;
113118
pub fn forbidden_emoji(input: ParseString) -> ParseResult<Token> {
114119
alt((box_t_left,box_tl_round,box_br_round, box_tr_round, box_bl_round, box_vert, box_cross, box_horz, box_t_right, box_t_top, box_t_bottom))(input)
115120
}
@@ -125,11 +130,13 @@ pub fn emoji(input: ParseString) -> ParseResult<Token> {
125130
Ok((input, Token{kind: TokenKind::Emoji, chars: g.chars().collect::<Vec<char>>(), src_range}))
126131
}
127132

133+
// alpha_token := alpha_literal_token ;
128134
pub fn alpha_token(input: ParseString) -> ParseResult<Token> {
129135
let (input, (g, src_range)) = range(alpha)(input)?;
130136
Ok((input, Token{kind: TokenKind::Alpha, chars: g.chars().collect::<Vec<char>>(), src_range}))
131137
}
132138

139+
// digit_token := digit_literal_token ;
133140
pub fn digit_token(input: ParseString) -> ParseResult<Token> {
134141
let (input, (g, src_range)) = range(digit)(input)?;
135142
Ok((input, Token{kind: TokenKind::Digit, chars: g.chars().collect::<Vec<char>>(), src_range}))
@@ -228,21 +235,25 @@ pub fn whitespace0(input: ParseString) -> ParseResult<()> {
228235
Ok((input, ()))
229236
}
230237

238+
// whitespace1 := one_or_more_whitespaces ;
231239
pub fn whitespace1(input: ParseString) -> ParseResult<()> {
232240
let (input, _) = many1(whitespace)(input)?;
233241
Ok((input, ()))
234242
}
235243

244+
// space_tab := space | tab ;
236245
pub fn space_tab(input: ParseString) -> ParseResult<Token> {
237246
let (input, space) = alt((space,tab))(input)?;
238247
Ok((input, space))
239248
}
240249

250+
// list_separator := optional_whitespace "," optional_whitespace ;
241251
pub fn list_separator(input: ParseString) -> ParseResult<()> {
242252
let (input,_) = nom_tuple((whitespace0,tag(","),whitespace0))(input)?;
243253
Ok((input, ()))
244254
}
245255

256+
// enum_separator := optional_whitespace "|" optional_whitespace ;
246257
pub fn enum_separator(input: ParseString) -> ParseResult<()> {
247258
let (input,_) = nom_tuple((whitespace0,tag("|"),whitespace0))(input)?;
248259
Ok((input, ()))
@@ -275,6 +286,7 @@ pub fn number(input: ParseString) -> ParseResult<Number> {
275286
Ok((input, Number::Real(real_num)))
276287
}
277288

289+
// real_number := optional_dash (hexadecimal_literal | decimal_literal | octal_literal | binary_literal | scientific_literal | rational_literal | float_literal | integer_literal) ;
278290
pub fn real_number(input: ParseString) -> ParseResult<RealNumber> {
279291
let (input, neg) = opt(dash)(input)?;
280292
let (input, result) = alt((hexadecimal_literal, decimal_literal, octal_literal, binary_literal, scientific_literal, rational_literal, float_literal, integer_literal))(input)?;
@@ -285,13 +297,15 @@ pub fn real_number(input: ParseString) -> ParseResult<RealNumber> {
285297
Ok((input, result))
286298
}
287299

300+
// rational_literal := integer_literal "/" integer_literal ;
288301
pub fn rational_literal(input: ParseString) -> ParseResult<RealNumber> {
289302
let (input, RealNumber::Integer(numerator)) = integer_literal(input)? else { unreachable!() };
290303
let (input, _) = slash(input)?;
291304
let (input, RealNumber::Integer(denominator)) = integer_literal(input)? else { unreachable!() };
292305
Ok((input, RealNumber::Rational((numerator,denominator))))
293306
}
294307

308+
// scientific_literal := (float_literal | integer_literal) ("e" | "E") (optional_plus | ε) (optional_dash | ε) (float_literal | integer_literal) ;
295309
pub fn scientific_literal(input: ParseString) -> ParseResult<RealNumber> {
296310
let (input, base) = match float_literal(input.clone()) {
297311
Ok((input, RealNumber::Float(base))) => {
@@ -454,6 +468,7 @@ pub fn kind_map(input: ParseString) -> ParseResult<Kind> {
454468
Ok((input, Kind::Map(Box::new(key_kind),Box::new(value_kind))))
455469
}
456470

471+
// kind_fxn := "(" kind (list_separator kind)* ")" "=" "(" kind (list_separator kind)* ")" ;
457472
pub fn kind_fxn(input: ParseString) -> ParseResult<Kind> {
458473
let (input, _) = left_parenthesis(input)?;
459474
let (input, input_kinds) = separated_list0(list_separator,kind)(input)?;

src/syntax/src/expressions.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ pub fn parenthetical_term(input: ParseString) -> ParseResult<Factor> {
3434
Ok((input, frmla))
3535
}
3636

37+
// negate_factor := "-" factor ;
3738
pub fn negate_factor(input: ParseString) -> ParseResult<Factor> {
3839
let (input, _) = dash(input)?;
3940
let (input, expr) = factor(input)?;
4041
Ok((input, Factor::Negate(Box::new(expr))))
4142
}
4243

44+
// not_factor := "not" factor ;
4345
pub fn not_factor(input: ParseString) -> ParseResult<Factor> {
4446
let (input, _) = not(input)?;
4547
let (input, expr) = factor(input)?;
@@ -261,6 +263,7 @@ pub fn statement_separator(input: ParseString) -> ParseResult<()> {
261263
Ok((input, ()))
262264
}
263265

266+
// function_define := identifier "(" (function_arg (list_separator function_arg)*)? ")" whitespace0 "=" whitespace0 (function_out_args | function_out_arg) define_operator (statement (whitespace1 | statement_separator)*) period ;
264267
pub fn function_define(input: ParseString) -> ParseResult<FunctionDefine> {
265268
let ((input, name)) = identifier(input)?;
266269
let ((input, _)) = left_parenthesis(input)?;
@@ -276,13 +279,15 @@ pub fn function_define(input: ParseString) -> ParseResult<FunctionDefine> {
276279
Ok((input,FunctionDefine{name,input: input_args,output,statements}))
277280
}
278281

282+
// function_out_args := "(" function_arg (list_separator function_arg)* ")" ;
279283
pub fn function_out_args(input: ParseString) -> ParseResult<Vec<FunctionArgument>> {
280284
let ((input, _)) = left_parenthesis(input)?;
281285
let ((input, args)) = separated_list1(list_separator,function_arg)(input)?;
282286
let ((input, _)) = right_parenthesis(input)?;
283287
Ok((input, args))
284288
}
285289

290+
// function_out_arg := function_arg ;
286291
pub fn function_out_arg(input: ParseString) -> ParseResult<Vec<FunctionArgument>> {
287292
let ((input, arg)) = function_arg(input)?;
288293
Ok((input, vec![arg]))

0 commit comments

Comments
 (0)