Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type system crate #27

Merged
merged 100 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
b342dd2
Typing crate and workspace dependencies
Rigidity Jul 18, 2024
e314575
Prototype new type system
Rigidity Jul 19, 2024
6f24cf4
Prototype new check system
Rigidity Jul 19, 2024
8067d60
Add Display for Check
Rigidity Jul 19, 2024
49b0104
Tests passing
Rigidity Jul 19, 2024
b347790
Refactor to prevent recursion
Rigidity Jul 19, 2024
7fd1507
More tests
Rigidity Jul 19, 2024
0fb848d
Reformat
Rigidity Jul 19, 2024
00af320
unpossible :)
Rigidity Jul 19, 2024
d39d550
Difference and testing
Rigidity Jul 19, 2024
f759737
Optimize checks
Rigidity Jul 19, 2024
3648b5c
Remove comments
Rigidity Jul 19, 2024
89402fc
Type path
Rigidity Jul 19, 2024
9700bd9
Generics maybe
Rigidity Jul 20, 2024
01b60bb
Allegedly add aliases
Rigidity Jul 20, 2024
b844f7a
Remove build hasher
Rigidity Jul 20, 2024
dc15630
Factor
Rigidity Jul 20, 2024
0f9ff29
Add stringification
Rigidity Jul 20, 2024
042cc83
WIP
Rigidity Jul 20, 2024
55c09c3
Tests passing
Rigidity Jul 22, 2024
bdb0200
Factor out simplify_check
Rigidity Jul 22, 2024
4a69c4b
Factor part 1
Rigidity Jul 22, 2024
d95d738
Multiple files
Rigidity Jul 22, 2024
4e24d7f
Factor out shape checks
Rigidity Jul 22, 2024
d32e072
Move simplify and tests
Rigidity Jul 22, 2024
0ff446e
More tests
Rigidity Jul 22, 2024
aa8a642
Refactor or
Rigidity Jul 23, 2024
7a03c5e
Bug fix
Rigidity Jul 23, 2024
45410d1
Simplify
Rigidity Jul 23, 2024
8257428
Move stringify check out
Rigidity Jul 23, 2024
56f253e
Add comparison tests
Rigidity Jul 23, 2024
157a82b
Add pair tests
Rigidity Jul 23, 2024
e7e434e
Generic inference test
Rigidity Jul 23, 2024
4d042d8
Refactor other functions
Rigidity Jul 23, 2024
f9ec679
Remove main.sym
Rigidity Jul 23, 2024
2336abe
Split f and r
Rigidity Jul 23, 2024
665852f
Check any point
Rigidity Jul 23, 2024
ce3cca3
Structs
Rigidity Jul 23, 2024
a963569
Callable
Rigidity Jul 23, 2024
7217c4e
Callable 2
Rigidity Jul 23, 2024
86f2dc9
Move check_type
Rigidity Jul 23, 2024
cdae353
Value check
Rigidity Jul 23, 2024
cb3a7d0
Organize import
Rigidity Jul 23, 2024
24758e2
Rename tests
Rigidity Jul 23, 2024
430d639
Move
Rigidity Jul 23, 2024
2f251ae
Fix callable
Rigidity Jul 23, 2024
4ad0e11
Temp
Rigidity Jul 23, 2024
e4004d5
Temp 2
Rigidity Jul 23, 2024
d189bf1
Temp
Rigidity Jul 23, 2024
606426a
Refactor attributes
Rigidity Jul 23, 2024
c833a00
Refactor and remove impossible
Rigidity Jul 23, 2024
41bd46b
Add enums and variants
Rigidity Jul 23, 2024
0591b69
Dependency
Rigidity Jul 23, 2024
0aab1c0
Temp 1
Rigidity Jul 23, 2024
b610217
Temp 2
Rigidity Jul 23, 2024
9f0ccd9
Temp 3
Rigidity Jul 23, 2024
633fe23
Temp 4
Rigidity Jul 23, 2024
ae039bb
Temp 5
Rigidity Jul 23, 2024
563cd4f
Temp 6
Rigidity Jul 23, 2024
7313c52
Temp 7
Rigidity Jul 23, 2024
8bd10ae
Add construction and deconstruction
Rigidity Jul 23, 2024
564e397
Temp 8
Rigidity Jul 23, 2024
15b8c4f
Temp 9
Rigidity Jul 23, 2024
f10a4c8
TEMP FINISH (NOT FINISHED)
Rigidity Jul 23, 2024
070730e
More worky
Rigidity Jul 23, 2024
34fe9d0
Add another test
Rigidity Jul 23, 2024
4beecba
Temp
Rigidity Jul 24, 2024
3d660ba
Temp
Rigidity Jul 24, 2024
88699be
Any type
Rigidity Jul 25, 2024
dd9dd8c
Refactor comparison
Rigidity Jul 25, 2024
8e11053
Bug fix
Rigidity Jul 25, 2024
05e9d23
More bug fixes
Rigidity Jul 25, 2024
968111e
Add tests for structs
Rigidity Jul 25, 2024
517b1c3
Overhaul
Rigidity Jul 25, 2024
0fb17d4
Fix
Rigidity Jul 25, 2024
1a2c3e1
Fixes 1
Rigidity Jul 25, 2024
cf97d88
Fixes
Rigidity Jul 26, 2024
135f459
Fixes
Rigidity Jul 26, 2024
57c0f69
Temp fix, I need more tests
Rigidity Jul 26, 2024
ad7a304
Remove panics
Rigidity Jul 26, 2024
4baf36e
Fix bug
Rigidity Jul 26, 2024
9f59957
Next
Rigidity Jul 26, 2024
84a4a49
More progress
Rigidity Jul 27, 2024
db75506
Remove optional
Rigidity Jul 27, 2024
24ca4fd
Fix generic inference
Rigidity Jul 31, 2024
e2708f7
Temp
Rigidity Aug 1, 2024
ab851f4
Temp
Rigidity Aug 1, 2024
e05f13e
Update tests
Rigidity Aug 1, 2024
05d18a0
Fix unknown
Rigidity Aug 1, 2024
f0447a1
Temp
Rigidity Aug 2, 2024
ae9fc62
Remove superset for performance
Rigidity Aug 2, 2024
91c95b4
Fix bug
Rigidity Aug 2, 2024
7873258
Next phase
Rigidity Aug 2, 2024
a293329
HashSet
Rigidity Aug 3, 2024
0acb1d7
Rename files
Rigidity Aug 3, 2024
11c220d
Rename compare
Rigidity Aug 3, 2024
9557f08
Initial simplification of type guards
Rigidity Aug 3, 2024
56204e2
Fix
Rigidity Aug 3, 2024
6eff77e
Fix priority
Rigidity Aug 3, 2024
e80eee2
One more
Rigidity Aug 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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