Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'v0.1-beta' into 'main'
Browse files Browse the repository at this point in the history
Release: v0.1-beta! 🥳

See merge request mech-lang/program!7
  • Loading branch information
cmontella committed Jan 4, 2023
2 parents 78c39aa + f849615 commit 9e1d39f
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 180 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ image: "rust:latest"

test:cargo:
script:
- rustup default nightly-2022-03-27
- rustup default nightly-2022-08-25
- rustup show
- rustc --version && cargo --version
- rustup component add rust-src
- cargo test --all
- cargo build --release
36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[package]
name = "mech-program"
version = "0.0.5"
version = "0.1.0"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "Organizes Mech cores into a coordinated program. Handles reading files, interfacing with libraries, and persisting changes top disk."
documentation = "http://docs.mech-lang.org"
homepage = "http://mech-lang.org"
homepage = "https://mech-lang.org"
repository = "https://github.com/mech-lang/program"
keywords = ["mech", "language", "programming", "dataflow", "runtime"]
categories = ["science::robotics", "science", "game-engines", "web-programming"]
license = "Apache-2.0"
readme = "README.md"
edition = "2018"
edition = "2021"

[badges]
gitlab = { repository = "mech-lang/program", branch = "main" }
maintenance = { status = "actively-developed" }

[dependencies]
mech-core = {git = "https://gitlab.com/mech-lang/core"}
mech-syntax = {git = "https://gitlab.com/mech-lang/syntax"}
mech-utilities = {git = "https://gitlab.com/mech-lang/utilities"}
mech-core = {git = "https://gitlab.com/mech-lang/core", branch = "v0.1-beta"}
mech-syntax = {git = "https://gitlab.com/mech-lang/syntax", branch = "v0.1-beta"}
mech-utilities = {git = "https://gitlab.com/mech-lang/utilities", branch = "v0.1-beta"}

time = "0.2.25"
serde = "1.0.123"
serde_derive = "1.0.123"
serde_json = "1.0.62"
bincode = "1.3.1"
libloading = "0.7.3"
time = "0.3.17"
serde = "1.0.152"
serde_derive = "1.0.152"
serde_json = "1.0.91"
bincode = "1.3.3"
libloading = "0.7.4"
lazy_static = "1.4.0"
reqwest = "0.9.22"
colored = "2.0.0"
crossbeam-channel = "0.5.1"
url = "2.2.1"
hashbrown = "0.12.1"
websocket = "0.26.2"
miniz_oxide = "0.4.4"
indexmap = "1.7.0"
crossbeam-channel = "0.5.6"
url = "2.3.1"
hashbrown = "0.13.1"
websocket = "0.26.5"
miniz_oxide = "0.6.2"
indexmap = "1.9.2"
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<p align="center">
<img width="500px" src="http://mech-lang.org/img/logo.png">
<img width="400px" src="https://mech-lang.org/img/logo.png">
</p>

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.
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.

Read about progress on our [blog](http://mech-lang.org/blog/), follow us on Twitter [@MechLang](https://twitter.com/MechLang), or join the mailing list: [talk@mech-lang.org](http://mech-lang.org/page/community/).
You can try Mech online at [https://mech-lang.org/try](https://mech-lang.org/try).

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).

Be sure to follow our [blog](https://mech-lang.org/blog/)([RSS](https://mech-lang.org/feed.xml))!

## Program

Organizes Mech cores into a coordinated program. Handles reading files, interfacing with libraries, and persisting changes top disk.

## Contents

- `Program` - holds a Mech core and channels for communicating to a RunLoop.
- `RunLoop` - holds a handle to a thread on which a `ProgramRunner` is running. It also holds channels for communicating between the ProgramRunner and a client, like an editor or a REPL.
- `Persister` - reads from and writes transactions to *.mdb files.
- `ProgramRunner` - Starts an infinite run loop on a thread that continually processes messages received messages.
- **program** - holds a Mech core and channels for communicating to a RunLoop.
- **runloop** - holds a handle to a thread on which a Mech program is running. It also holds channels for communicating between and editor, REPL, or remote core.
- **persister** - reads from and writes transactions to *.blx files.

## Project Status

Mech is currently in the **alpha** stage of development. This means that while some features work and are tested, programs are still likely to crash and produce incorrect results. We've implemented some language features, but many are not yet implemented.

Feel free to use the language for your own satisfaction, but please don't use it for anything important.
Mech is currently in the **beta** stage of development. This means that the language is at a suitable stage for a wider audience. While most language feature implementations are started, none are finished, and some new features may, while others could be removed. Backwards and forwards compatibility of Mech programs is not guaranteed at this time.

## License

Expand Down
30 changes: 20 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern crate time;
extern crate mech_core;
use mech_core::*;
extern crate mech_syntax;
use mech_syntax::formatter::Formatter;
extern crate mech_utilities;
extern crate colored;
extern crate websocket;
Expand All @@ -51,7 +52,7 @@ pub use self::program::{Program};
pub use self::runloop::{ProgramRunner, RunLoop, ClientMessage};
pub use self::persister::{Persister};

pub fn format_errors(errors: &Vec<MechErrorKind>) -> String {
pub fn format_errors(errors: &Vec<MechError>) -> String {
let mut formatted_errors = "".to_string();
let plural = if errors.len() == 1 {
""
Expand All @@ -61,15 +62,22 @@ pub fn format_errors(errors: &Vec<MechErrorKind>) -> String {
let error_notice = format!("🐛 Found {} Error{}:\n", &errors.len(), plural);
formatted_errors = format!("{}\n{}\n\n", formatted_errors, error_notice);
for error in errors {
formatted_errors = format!("{}{} {} {} {}\n\n", formatted_errors, "---".truecolor(246,192,78), "Block".truecolor(246,192,78), "BLOCKNAME", "--------------------------------------------".truecolor(246,192,78));
formatted_errors = format!("{}\n{:?}\n", formatted_errors, error);
formatted_errors = format!("{}\n", formatted_errors);
formatted_errors = format!("{}\n{}",formatted_errors, "----------------------------------------------------------------\n\n".truecolor(246,192,78));
formatted_errors = format!("{}{}\n\n", formatted_errors, "───────────────────────────────────────────────────────────────────".truecolor(246,192,78));
match &error.kind {
MechErrorKind::ParserError(ast,report,msg) => { formatted_errors = format!("{}{}", formatted_errors, msg);}
MechErrorKind::MissingTable(table_id) => {
formatted_errors = format!("{} Missing table: {}\n", formatted_errors, error.msg);
}
_ => {
formatted_errors = format!("{}\n{:?}\n", formatted_errors, error);
}
}
}
formatted_errors = format!("{}\n{}",formatted_errors, "───────────────────────────────────────────────────────────────────\n\n".truecolor(246,192,78));
formatted_errors
}

pub fn download_machine(machine_name: &str, name: &str, path_str: &str, ver: &str, outgoing: Option<crossbeam_channel::Sender<ClientMessage>>) -> Result<Library,Box<dyn std::error::Error>> {
pub fn download_machine(machine_name: &str, name: &str, path_str: &str, ver: &str, outgoing: Option<crossbeam_channel::Sender<ClientMessage>>) -> Result<Library,MechError> {
create_dir("machines");

let machine_file_path = format!("machines/{}",machine_name);
Expand All @@ -78,7 +86,7 @@ pub fn download_machine(machine_name: &str, name: &str, path_str: &str, ver: &st
// Download from the web
if path.to_str().unwrap().starts_with("https") {
match outgoing {
Some(ref sender) => {sender.send(ClientMessage::String(format!("{} {} v{}", "[Downloading]".bright_cyan(), name, ver)));}
Some(ref sender) => {sender.send(ClientMessage::String(format!("{} {} v{}", "[Downloading]".truecolor(153,221,85), name, ver)));}
None => (),
}
let machine_url = format!("{}/{}", path_str, machine_name);
Expand Down Expand Up @@ -108,7 +116,7 @@ pub fn download_machine(machine_name: &str, name: &str, path_str: &str, ver: &st
// Load from a local directory
} else {
match outgoing {
Some(sender) => {sender.send(ClientMessage::String(format!("{} {} v{}", "[Loading]".bright_cyan(), name, ver)));}
Some(sender) => {sender.send(ClientMessage::String(format!("{} {} v{}", "[Loading]".truecolor(153,221,85), name, ver)));}
None => (),
}
let machine_path = format!("{}{}", path_str, machine_name);
Expand All @@ -120,6 +128,8 @@ pub fn download_machine(machine_name: &str, name: &str, path_str: &str, ver: &st
}
let machine_file_path = format!("machines/{}",machine_name);
let message = format!("Can't load library {:?}", machine_file_path);
let machine = unsafe{Library::new(machine_file_path).expect(&message)};
Ok(machine)
match unsafe{Library::new(machine_file_path)} {
Ok(machine) => Ok(machine),
Err(err) => Err(MechError{msg: "".to_string(), id: 1273, kind: MechErrorKind::GenericError(format!("{:?}",message))}),
}
}
Loading

0 comments on commit 9e1d39f

Please sign in to comment.