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 16, 2024
2 parents 55574e0 + d093f84 commit 198cde4
Show file tree
Hide file tree
Showing 24 changed files with 1,414 additions and 3,642 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test:cargo:
script:
- rustup show
- rustup default nightly-2024-05-26
- wasm-pack --version
- wasm-pack build wasm-notebook --target web
#- wasm-pack --version
#- wasm-pack build wasm-notebook --target web
- cargo build --bin mech --release
- cargo test --package mech-syntax --release
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech"
version = "0.2.1"
version = "0.2.2"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "Toolchain for the Mech programming language."
documentation = "https://mech-lang.org/docs"
Expand All @@ -18,10 +18,10 @@ gitlab = { repository = "mech-lang/mech", branch = "main" }
maintenance = { status = "actively-developed" }

[dependencies]
mech-core = "0.2.1"
mech-syntax = {version = "0.2.1", features = ["lang-server"]}
#mech-program = "0.2.1"
mech-utilities = "0.2.1"
mech-core = "0.2.2"
mech-syntax = {version = "0.2.2", features = ["lang-server"]}
#mech-program = "0.2.2"
mech-utilities = "0.2.2"

clap = {version = "4.5.8", features = ["cargo"]}
colored = "2.1.0"
Expand Down
18 changes: 9 additions & 9 deletions src/bin/mech.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![feature(hash_extract_if)]
#![allow(warnings)]
use mech_syntax::parser;
use mech_syntax::ast::Ast;
use mech_syntax::compiler::Compiler;
use mech_core::*;
use mech_syntax::parser2;
//use mech_syntax::analyzer::*;
Expand All @@ -25,7 +22,7 @@ use tabled::{
};

fn main() -> Result<(), MechError> {
let version = "0.2.1";
let version = "0.2.2";
let text_logo = r#"
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │
Expand Down Expand Up @@ -95,8 +92,8 @@ fn main() -> Result<(), MechError> {
}
},
Err(err) => {
if let MechErrorKind::ParserError(tree, report, _) = err.kind {
parser::print_err_report(&s, &report);
if let MechErrorKind::ParserError(report, _) = err.kind {
parser2::print_err_report(&s, &report);
} else {
panic!("Unexpected error type");
}
Expand Down Expand Up @@ -131,11 +128,14 @@ fn main() -> Result<(), MechError> {
match parser2::parse(&input) {
Ok(tree) => {
let result = intrp.interpret(&tree);
println!("{:?}", result);
match result {
Ok(r) => println!("{}", r.pretty_print()),
Err(err) => println!("{:?}", err),
}
}
Err(err) => {
if let MechErrorKind::ParserError(tree, report, _) = err.kind {
parser::print_err_report(&input, &report);
if let MechErrorKind::ParserError(report, _) = err.kind {
parser2::print_err_report(&input, &report);
} else {
panic!("Unexpected error type");
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/mech.rs.old
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn main() -> Result<(), MechError> {

#[cfg(windows)]
control::set_virtual_terminal(true).unwrap();
let version = "0.2.1";
let version = "0.2.2";
let matches = Command::new("Mech")
.version(version)
.author("Corey Montella corey@mech-lang.org")
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.1"
version = "0.2.2"
authors = ["Corey Montella <corey@mech-lang.org>"]
description = "The Mech language runtime."
documentation = "http://docs.mech-lang.org"
Expand Down
6 changes: 4 additions & 2 deletions src/core/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::time::{Instant};

use std::collections::VecDeque;
use mech_core::*;
use mech_core::function::table;
//use mech_core::function::table;
use nalgebra::DMatrix;

use std::fmt::*;
Expand All @@ -33,7 +33,7 @@ use std::ops::*;
extern crate time;

fn main() -> std::result::Result<(),MechError> {

/*
//let now = Instant::now();
let n = 1e7 as usize;
Expand Down Expand Up @@ -339,5 +339,7 @@ fn main() -> std::result::Result<(),MechError> {
//println!("{:0.4?} s", time / 1e9);
//println!("{:?}", core);
Ok(())
}*/
Ok(())
}
2 changes: 1 addition & 1 deletion src/core/src/bin/states.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate time;
use std::time::Instant;
use mech_core::statemachines::*;
//use mech_core::statemachines::*;
use mech_core::*;
use std::sync::{Arc, Mutex};
use std::time::Duration;
Expand Down
13 changes: 7 additions & 6 deletions src/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::nodes::{SourceRange, Token};

type Rows = usize;
type Cols = usize;
pub type ParserErrorReport = Vec<ParserErrorContext>;

#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct MechError {
Expand All @@ -30,10 +31,10 @@ pub enum MechErrorKind {
UndefinedField(u64), // Accessed a field of a record that's not defined
UndefinedVariable(u64), // Accessed a variable that's not defined
UndefinedKind(u64), // Used a kind that's not defined
MissingTable(TableId), // TableId of missing table
MissingBlock(BlockId), // BlockId of missing block
MissingTable(u64), // TableId of missing table
MissingBlock(u64), // BlockId of missing block
PendingExpression, // id of pending variable
PendingTable(TableId), // TableId of pending table
PendingTable(u64), // TableId of pending table
DimensionMismatch(Vec<(Rows,Cols)>), // Argument dimensions are mismatched ((row,col),(row,col))
//MissingColumn((TableId,TableIndex)), // The identified table is missing a needed column
//ColumnKindMismatch(Vec<ValueKind>), // Excepted kind versus given kind
Expand All @@ -58,10 +59,10 @@ pub enum MechErrorKind {
ExpectedNumericForSize, // When something non-numeric is passed as a size
MatrixMustHaveHomogenousKind, // When multiple element kinds are specified for a matrix
IncorrectNumberOfArguments,
UnhandledTableShape(TableShape),
//UnhandledTableShape(TableShape),
TooManyInputArguments(usize,usize), // (given,expected)
ParserError(nodes::ParserNode, ParserErrorReport, String),
MissingCapability(Capability),
ParserError(ParserErrorReport, String),
//MissingCapability(Capability),
InvalidCapabilityToken,
None,
}
Expand Down
77 changes: 39 additions & 38 deletions src/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,59 @@ use num_traits::*;
use std::ops::*;


mod column;
pub mod value;
//mod column;
//pub mod value;
mod error;
mod table;
mod transformation;
mod database;
mod user_functions;
pub mod function;
mod block;
mod core;
mod schedule;
//mod table;
//mod transformation;
//mod database;
//mod user_functions;
//pub mod function;
//mod block;
//mod core;
//mod schedule;
pub mod nodes;
mod capabilities;
mod types;
pub mod statemachines;
mod enums;

pub use self::core::Core;
pub use self::table::*;
pub use self::column::*;
pub use self::value::*;
//mod capabilities;
//mod types;
//pub mod statemachines;
//mod enums;

//pub use self::core::Core;
//pub use self::table::*;
//pub use self::column::*;
//pub use self::value::*;
pub use self::error::*;
pub use self::transformation::Transformation;
pub use self::database::*;
#[cfg(feature = "stdlib")]
pub use self::function::*;
pub use self::block::*;
pub use self::schedule::*;
pub use self::user_functions::*;
pub use self::capabilities::*;
pub use self::types::*;
pub use self::enums::*;
pub use self::statemachines::*;

#[derive(Debug, Clone)]
//pub use self::transformation::Transformation;
//pub use self::database::*;
//#[cfg(feature = "stdlib")]
//pub use self::function::*;
//pub use self::block::*;
//pub use self::schedule::*;
//pub use self::user_functions::*;
//pub use self::capabilities::*;
//pub use self::types::*;
//pub use self::enums::*;
//pub use self::statemachines::*;

/*#[derive(Debug, Clone)]
pub enum SectionElement {
Block(Block),
UserFunction(UserFunction),
}
}*/

pub fn resize_one(block: &mut Block, out: &Out) -> std::result::Result<(),MechError> {
/*pub fn resize_one(block: &mut Block, out: &Out) -> std::result::Result<(),MechError> {
let (out_table_id,_,_) = out;
let out_table = block.get_table(out_table_id)?;
let mut out_brrw = out_table.borrow_mut();
out_brrw.resize(1,1);
Ok(())
}
}*/

pub trait Machine {
/*pub trait Machine {
fn name(&self) -> String;
fn id(&self) -> u64;
fn on_change(&mut self, table: &Table) -> Result<(), MechError>;
}
}*/


#[derive(Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
Expand Down Expand Up @@ -205,7 +205,7 @@ pub const WORDLIST: &[&str;256] = &[
"ulu", "fix", "gry", "hol", "jup", "lam", "pas",
"rom", "sne", "ten", "uta"];


/*
#[derive(Debug)]
pub enum LineKind {
Title((String,String)),
Expand Down Expand Up @@ -541,3 +541,4 @@ impl fmt::Debug for BoxPrinter {
Ok(())
}
}
*/
Loading

0 comments on commit 198cde4

Please sign in to comment.