Skip to content

Commit

Permalink
Merge pull request #27 from Rigidity/type-system-crate
Browse files Browse the repository at this point in the history
Type system crate
  • Loading branch information
Rigidity authored Aug 3, 2024
2 parents e8d15fa + e80eee2 commit a3e52bd
Show file tree
Hide file tree
Showing 115 changed files with 5,529 additions and 2,932 deletions.
71 changes: 65 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 35 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ keywords = ["chia", "blockchain", "crypto"]
categories = ["cryptography::cryptocurrencies", "development-tools"]

[workspace.lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 }
rust_2021_compatibility = { level = "deny", priority = -1 }
future_incompatible = { level = "deny", priority = -1 }
nonstandard_style = { level = "deny", priority = -1 }
unsafe_code = "deny"
rust_2018_idioms = "deny"
rust_2021_compatibility = "deny"
future_incompatible = "deny"
non_ascii_idents = "deny"
nonstandard_style = "deny"
unused_extern_crates = "deny"
trivial_casts = "deny"
trivial_numeric_casts = "deny"
Expand All @@ -26,11 +26,41 @@ missing_debug_implementations = "warn"
missing_copy_implementations = "warn"

[workspace.lints.clippy]
all = "deny"
all = { level = "deny", priority = -1 }
pedantic = { level = "warn", priority = -1 }
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
multiple_crate_versions = "allow"
must_use_candidate = "allow"
too_many_lines = "allow"

[workspace.dependencies]
rue-parser = { path = "./crates/rue-parser", version = "0.1.1" }
rue-compiler = { path = "./crates/rue-compiler", version = "0.1.1" }
rue-typing = { path = "./crates/rue-typing", version = "0.1.1" }
rue-clvm = { path = "./crates/rue-clvm", version = "0.1.1" }
rue-lexer = { path = "./crates/rue-lexer", version = "0.1.1" }
clvmr_old = { version = "0.3.2", package = "clvmr" }
clvmr = "0.6.1"
clap = "4.5.4"
hex = "0.4.3"
clvm_tools_rs = "0.1.41"
thiserror = "1.0.61"
num-bigint = "0.4.6"
num-traits = "0.2.19"
num-derive = "0.4.2"
id-arena = "2.2.1"
indexmap = "2.2.6"
rowan = "0.15.15"
log = "0.4.21"
indoc = "2.0.5"
tokio = "1.37.0"
tower-lsp = "0.20.0"
clvm-utils = "0.6.0"
toml = "0.8.12"
serde = "1.0.197"
walkdir = "2.5.0"
anyhow = "1.0.86"
hashbrown = "0.14.5"
ahash = "0.8.11"
12 changes: 6 additions & 6 deletions crates/rue-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ categories = { workspace = true }
workspace = true

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
rue-parser = { path = "../../crates/rue-parser", version = "0.1.0" }
rue-compiler = { path = "../../crates/rue-compiler", version = "0.1.0" }
rue-clvm = { path = "../../crates/rue-clvm", version = "0.1.0" }
clvmr = "0.6.1"
hex = "0.4.3"
clap = { workspace = true, features = ["derive"] }
rue-parser = { workspace = true }
rue-compiler = { workspace = true }
rue-clvm = { workspace = true }
clvmr = { workspace = true }
hex = { workspace = true }

[[bin]]
name = "rue"
Expand Down
23 changes: 18 additions & 5 deletions crates/rue-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fs;
use clap::Parser;
use clvmr::{serde::node_to_bytes, Allocator, NodePtr};
use rue_clvm::{parse_clvm, run_clvm, stringify_clvm};
use rue_compiler::{compile, Diagnostic, DiagnosticKind};
use rue_compiler::{compile_raw, Diagnostic, DiagnosticKind};
use rue_parser::{line_col, parse, LineCol};

/// CLI tools for working with the Rue compiler.
Expand All @@ -20,23 +20,31 @@ enum Command {
/// A list of parameters to run the compiled program with.
#[clap(long, short = 'r')]
run: Option<Option<String>>,

/// Whether to exclude the standard library.
#[clap(long, short = 'n')]
no_std: bool,
},

/// Check a Rue source file for errors.
Check {
/// The source file to check.
file: String,

/// Whether to exclude the standard library.
#[clap(long, short = 'n')]
no_std: bool,
},
}

fn main() {
match Command::parse() {
Command::Build { file, run } => build(file, true, &run),
Command::Check { file } => build(file, false, &None),
Command::Build { file, run, no_std } => build(file, true, &run, no_std),
Command::Check { file, no_std } => build(file, false, &None, no_std),
}
}

fn build(file: String, should_compile: bool, run: &Option<Option<String>>) {
fn build(file: String, should_compile: bool, run: &Option<Option<String>>, no_std: bool) {
let source = fs::read_to_string(file).expect("could not read source file");
let (ast, errors) = parse(&source);

Expand All @@ -49,7 +57,12 @@ fn build(file: String, should_compile: bool, run: &Option<Option<String>>) {
}

let mut allocator = Allocator::new();
let output = compile(&mut allocator, &ast, should_compile && errors.is_empty());
let output = compile_raw(
&mut allocator,
&ast,
should_compile && errors.is_empty(),
!no_std,
);

if print_diagnostics(&source, &output.diagnostics) {
return;
Expand Down
12 changes: 6 additions & 6 deletions crates/rue-clvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ categories = { workspace = true }
workspace = true

[dependencies]
clvmr = "0.6.1"
clvmr_old = { version = "0.3.2", package = "clvmr" }
clvm_tools_rs = "0.1.41"
thiserror = "1.0.61"
num-bigint = "0.4.6"
num-traits = "0.2.19"
clvmr = { workspace = true }
clvmr_old = { workspace = true }
clvm_tools_rs = { workspace = true }
thiserror = { workspace = true }
num-bigint = { workspace = true }
num-traits = { workspace = true }
23 changes: 12 additions & 11 deletions crates/rue-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ categories = { workspace = true }
workspace = true

[dependencies]
rue-parser = { path = "../rue-parser", version = "0.1.0" }
rue-clvm = { path = "../rue-clvm", version = "0.1.0" }
clvmr = "0.6.1"
id-arena = "2.2.1"
indexmap = "2.2.6"
rowan = "0.15.15"
num-traits = "0.2.18"
num-bigint = "0.4.4"
log = "0.4.21"
hex = "0.4.3"
indoc = "2.0.5"
rue-parser = { workspace = true }
rue-clvm = { workspace = true }
rue-typing = { workspace = true }
clvmr = { workspace = true }
id-arena = { workspace = true }
indexmap = { workspace = true }
rowan = { workspace = true }
num-traits = { workspace = true }
num-bigint = { workspace = true }
log = { workspace = true }
hex = { workspace = true }
indoc = { workspace = true }
Loading

0 comments on commit a3e52bd

Please sign in to comment.