diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index ea8904f..af39515 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -8,7 +8,6 @@ on: env: CARGO_TERM_COLOR: always - NO_COLOR: 1 jobs: build: diff --git a/Cargo.lock b/Cargo.lock index 1985f3f..5b7898d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -960,22 +960,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pete" -version = "0.1.0" -dependencies = [ - "clap 4.5.8", - "petr-api", - "petr-pkg", - "petr-profiling", - "petr-resolve", - "petr-typecheck", - "stdlib", - "termcolor", - "thiserror", - "toml", -] - [[package]] name = "petr-api" version = "0.1.0" @@ -1012,6 +996,22 @@ dependencies = [ "petr-utils", ] +[[package]] +name = "petr-cli" +version = "0.1.0" +dependencies = [ + "clap 4.5.8", + "petr-api", + "petr-pkg", + "petr-profiling", + "petr-resolve", + "petr-stdlib", + "petr-typecheck", + "termcolor", + "thiserror", + "toml", +] + [[package]] name = "petr-codegen" version = "0.1.0" @@ -1082,7 +1082,7 @@ version = "0.1.0" dependencies = [ "expect-test", "petr-api", - "stdlib", + "petr-stdlib", "wasm-bindgen", ] @@ -1108,6 +1108,10 @@ dependencies = [ "thiserror", ] +[[package]] +name = "petr-stdlib" +version = "0.1.0" + [[package]] name = "petr-typecheck" version = "0.1.0" @@ -1137,9 +1141,9 @@ dependencies = [ "petr-ir", "petr-parse", "petr-resolve", + "petr-stdlib", "petr-typecheck", "petr-utils", - "stdlib", "thiserror", ] @@ -1292,10 +1296,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "stdlib" -version = "0.1.0" - [[package]] name = "strsim" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 67443ed..e4dca87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "petr-parse", "petr-fmt", "petr-utils", - "pete", + "petr-cli", "petr-codegen", "petr-ast", "petr-typecheck", @@ -15,5 +15,14 @@ members = [ "petr-pkg", "petr-profiling", "petr-api", - "petr-playground" -, "stdlib"] + "petr-playground", + "petr-stdlib", +] + +[workspace.package] +version = "0.1.0" +edition = "2021" +homepage = "https://petr.sh" +license = "MIT" +repository = "https://github.com/sezna/petr" +authors = ["Alex Hansen "] diff --git a/justfile b/justfile index 67f4dfb..c099d8f 100644 --- a/justfile +++ b/justfile @@ -2,7 +2,24 @@ alias t := test test: - CARGO_TERM_COLOR=always NO_COLOR=1 cargo test + cargo test -update-expects: - CARGO_TERM_COLOR=always NO_COLOR=1 UPDATE_EXPECT=1 cargo test +u-exp: + UPDATE_EXPECT=1 cargo test + +publish: + cargo publish -p petr-utils + cargo publish -p petr-ast + cargo publish -p petr-profiling + cargo publish -p petr-parse + cargo publish -p petr-fmt + cargo publish -p petr-bind + cargo publish -p petr-resolve + cargo publish -p petr-typecheck + cargo publish -p petr-ir + cargo publish -p petr-vm + cargo publish -p petr-codegen + cargo publish -p petr-pkg + cargo publish -p petr-api + cargo publish -p petr-playground + cargo publish -p petr-cli diff --git a/pete/Cargo.toml b/pete/Cargo.toml deleted file mode 100644 index 15177d0..0000000 --- a/pete/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "pete" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -clap = { version = "4.5.4", features = ["derive"] } -petr-api = { "path" = "../petr-api", features = ["fancy", "default"] } -petr-profiling = { "path" = "../petr-profiling" } -petr-resolve = { "path" = "../petr-resolve" } -petr-typecheck = { "path" = "../petr-typecheck" } -thiserror = "1.0" -toml = "0.8" -termcolor = { version = "1.4" } -petr-pkg = { "path" = "../petr-pkg" } -stdlib = { "path" = "../stdlib" } diff --git a/petr-api/Cargo.toml b/petr-api/Cargo.toml index 1b639c1..6925a15 100644 --- a/petr-api/Cargo.toml +++ b/petr-api/Cargo.toml @@ -1,21 +1,27 @@ [package] name = "petr-api" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "re-exports of useful APIs for the petr compiler" +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-parse = { "path" = "../petr-parse" } -petr-utils = { "path" = "../petr-utils", optional = true } -petr-vm = { "path" = "../petr-vm" } -petr-ir = { "path" = "../petr-ir" } -petr-fmt = { path = "../petr-fmt" } -petr-typecheck = { "path" = "../petr-typecheck" } -petr-resolve = { "path" = "../petr-resolve", optional = true } -petr-pkg = { "path" = "../petr-pkg", optional = true } +petr-parse = { "path" = "../petr-parse", version = "0.1.0" } +petr-utils = { "path" = "../petr-utils", optional = true, version = "0.1.0" } +petr-vm = { "path" = "../petr-vm", version = "0.1.0" } +petr-ir = { "path" = "../petr-ir", version = "0.1.0" } +petr-fmt = { path = "../petr-fmt", version = "0.1.0" } +petr-typecheck = { "path" = "../petr-typecheck", version = "0.1.0" } +petr-resolve = { "path" = "../petr-resolve", version = "0.1.0", optional = true } +petr-pkg = { "path" = "../petr-pkg", version = "0.1.0", optional = true } termcolor = { version = "1.4", optional = true } -petr-profiling = { path = "../petr-profiling" } +petr-profiling = { path = "../petr-profiling", version = "0.1.0" } miette = { version = "5.10", optional = true } thiserror = "1.0" toml = "0.8" diff --git a/petr-api/src/lib.rs b/petr-api/src/lib.rs index 12140e6..aff46a6 100644 --- a/petr-api/src/lib.rs +++ b/petr-api/src/lib.rs @@ -5,7 +5,6 @@ use std::{ fs, path::{Path, PathBuf}, - rc::Rc, }; pub use petr_fmt::{format_sources, Formattable, FormatterConfig, FormatterContext}; @@ -21,6 +20,8 @@ pub use petr_vm::Vm; use termcolor::{ColorChoice, ColorSpec, StandardStream, WriteColor}; pub mod error { + use petr_ir::LoweringError; + use petr_utils::SpannedItem; use thiserror::Error; #[derive(Error, Debug)] pub enum PeteError { @@ -31,6 +32,8 @@ pub mod error { #[cfg(not(feature = "no_std"))] #[error(transparent)] Pkg(#[from] petr_pkg::error::PkgError), + #[error("Failed to lower code")] + FailedToLower(#[from] SpannedItem), } } @@ -153,12 +156,9 @@ pub fn compile( interner = new_interner; parse_errs.append(&mut new_parse_errs); source_map = new_source_map; - let name = Identifier { - id: interner.insert(Rc::from(item.manifest.name)), - }; dependencies.push(petr_resolve::Dependency { key: item.key, - name, + name: item.manifest.name, dependencies: item.depends_on, ast, }); @@ -193,8 +193,8 @@ pub fn compile( // errs.append(&mut type_errs); timings.start("lowering"); - let lowerer: Lowerer = Lowerer::new(type_checker); + let lowerer = Lowerer::new(type_checker); timings.end("lowering"); - Ok(lowerer) + Ok(lowerer?) } diff --git a/petr-ast/Cargo.toml b/petr-ast/Cargo.toml index 9020603..02e1b68 100644 --- a/petr-ast/Cargo.toml +++ b/petr-ast/Cargo.toml @@ -1,9 +1,15 @@ [package] name = "petr-ast" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "AST types for the petr language" +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-utils = { path = "../petr-utils" } +petr-utils = { path = "../petr-utils", version = "0.1.0" } diff --git a/petr-bind/Cargo.toml b/petr-bind/Cargo.toml index 9a0d531..382ab58 100644 --- a/petr-bind/Cargo.toml +++ b/petr-bind/Cargo.toml @@ -1,15 +1,21 @@ [package] name = "petr-bind" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "The binding stage of the petr compiler" +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-utils = { path = "../petr-utils" } -petr-ast = { path = "../petr-ast" } +petr-utils = { path = "../petr-utils", version = "0.1.0" } +petr-ast = { path = "../petr-ast", version = "0.1.0" } [dev-dependencies] expect-test = "1.5.0" -petr-parse = { path = "../petr-parse" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } diff --git a/petr-cli/Cargo.toml b/petr-cli/Cargo.toml new file mode 100644 index 0000000..fd9a187 --- /dev/null +++ b/petr-cli/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "petr-cli" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "command line tool for compiling petr code" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.5.4", features = ["derive"] } +petr-api = { "path" = "../petr-api", features = ["fancy", "default"], version = "0.1.0" } +petr-profiling = { "path" = "../petr-profiling", version = "0.1.0" } +petr-resolve = { "path" = "../petr-resolve", version = "0.1.0" } +petr-typecheck = { "path" = "../petr-typecheck", version = "0.1.0" } +thiserror = "1.0" +toml = "0.8" +termcolor = { version = "1.4" } +petr-pkg = { "path" = "../petr-pkg", version = "0.1.0" } +petr-stdlib = { "path" = "../petr-stdlib", version = "0.1.0" } + +[[bin]] +name = "pete" +path = "src/main.rs" diff --git a/pete/src/main.rs b/petr-cli/src/main.rs similarity index 99% rename from pete/src/main.rs rename to petr-cli/src/main.rs index 0f3fea3..65f6c3d 100644 --- a/pete/src/main.rs +++ b/petr-cli/src/main.rs @@ -170,7 +170,7 @@ pub fn compile( let mut dependencies = Vec::with_capacity(build_plan.items.len() + 1); // add the stdlib - let parser = Parser::new_with_existing_interner_and_source_map(stdlib::stdlib(), interner, source_map); + let parser = Parser::new_with_existing_interner_and_source_map(petr_stdlib::stdlib(), interner, source_map); let (dep_ast, mut new_parse_errs, mut interner, mut source_map) = parser.into_result(); parse_errs.append(&mut new_parse_errs); diff --git a/pete/tmp.swim b/petr-cli/tmp.swim similarity index 100% rename from pete/tmp.swim rename to petr-cli/tmp.swim diff --git a/petr-codegen/Cargo.toml b/petr-codegen/Cargo.toml index c9ec6ce..93a9a51 100644 --- a/petr-codegen/Cargo.toml +++ b/petr-codegen/Cargo.toml @@ -1,12 +1,18 @@ [package] name = "petr-codegen" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "Codegen stage of the petr compiler" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-ir = { path = "../petr-ir" } +petr-ir = { path = "../petr-ir", version = "0.1.0" } cranelift = "0.108.1" cranelift-native = "0.108.1" diff --git a/petr-fmt/Cargo.lock b/petr-fmt/Cargo.lock index 05a4c02..86f10bb 100644 --- a/petr-fmt/Cargo.lock +++ b/petr-fmt/Cargo.lock @@ -299,7 +299,7 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "petr-fmt" -version = "0.1.0" +version.workspace = true dependencies = [ "expect-test", "petr-parse", @@ -307,7 +307,7 @@ dependencies = [ [[package]] name = "petr-parse" -version = "0.1.0" +version.workspace = true dependencies = [ "expect-test", "logos", @@ -318,7 +318,7 @@ dependencies = [ [[package]] name = "petr-utils" -version = "0.1.0" +version.workspace = true dependencies = [ "miette", ] diff --git a/petr-fmt/Cargo.toml b/petr-fmt/Cargo.toml index 6fe8095..e4aba3a 100644 --- a/petr-fmt/Cargo.toml +++ b/petr-fmt/Cargo.toml @@ -1,14 +1,20 @@ [package] name = "petr-fmt" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "Formatter for the petr language" +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-parse = { path = "../petr-parse" } -petr-utils = { path = "../petr-utils" } -petr-ast = { path = "../petr-ast" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } +petr-utils = { path = "../petr-utils", version = "0.1.0" } +petr-ast = { path = "../petr-ast", version = "0.1.0" } structopt = { version = "0.3.26", features = ["color"] } [dev-dependencies] diff --git a/petr-ir/Cargo.toml b/petr-ir/Cargo.toml index 3db4edf..7eeba7b 100644 --- a/petr-ir/Cargo.toml +++ b/petr-ir/Cargo.toml @@ -1,20 +1,26 @@ [package] name = "petr-ir" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "target agnostic IR for the petr language" +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-utils = { path = "../petr-utils", optional = true } -petr-typecheck = { path = "../petr-typecheck" } +petr-utils = { path = "../petr-utils", version = "0.1.0", optional = true } +petr-typecheck = { path = "../petr-typecheck", version = "0.1.0" } miette = { version = "5.10", features = ["fancy"] } thiserror = "1.0.61" [dev-dependencies] -petr-parse = { path = "../petr-parse" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } expect-test = "1.5.0" -petr-resolve = { path = "../petr-resolve" } +petr-resolve = { path = "../petr-resolve", version = "0.1.0" } [features] debug = ["petr-utils/debug"] diff --git a/petr-parse/Cargo.lock b/petr-parse/Cargo.lock index 7c39bf1..1808eb3 100644 --- a/petr-parse/Cargo.lock +++ b/petr-parse/Cargo.lock @@ -299,7 +299,7 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "petr-parse" -version = "0.1.0" +version.workspace = true dependencies = [ "expect-test", "logos", @@ -310,7 +310,7 @@ dependencies = [ [[package]] name = "petr-utils" -version = "0.1.0" +version.workspace = true dependencies = [ "miette", ] diff --git a/petr-parse/Cargo.toml b/petr-parse/Cargo.toml index e441a50..4a0ffc6 100644 --- a/petr-parse/Cargo.toml +++ b/petr-parse/Cargo.toml @@ -1,16 +1,22 @@ [package] name = "petr-parse" -version = "0.1.0" -edition = "2021" +description = "parser for the petr language" + +version.workspace = true +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] logos = "0.14.0" miette = { version = "5.10", features = ["fancy"] } -petr-utils = { path = "../petr-utils" } +petr-utils = { path = "../petr-utils", version = "0.1.0" } thiserror = "1.0.61" -petr-ast = { path = "../petr-ast" } +petr-ast = { path = "../petr-ast", version = "0.1.0" } [dev-dependencies] expect-test = "1.5.0" diff --git a/petr-pkg/Cargo.toml b/petr-pkg/Cargo.toml index 375b16d..fd9395d 100644 --- a/petr-pkg/Cargo.toml +++ b/petr-pkg/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "petr-pkg" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "package management for the petr language" [dependencies] bcrypt = "0.15.1" @@ -10,6 +16,6 @@ dirs = "5.0.1" git2 = "0.19.0" serde = { version = "1.0.203", features = ["derive"] } toml = "0.8.14" -petr-fmt = { path = "../petr-fmt" } +petr-fmt = { path = "../petr-fmt", version = "0.1.0" } thiserror = "1.0.61" termcolor = "1.4.1" diff --git a/petr-playground/Cargo.toml b/petr-playground/Cargo.toml index f7346c0..b02d338 100644 --- a/petr-playground/Cargo.toml +++ b/petr-playground/Cargo.toml @@ -1,17 +1,19 @@ [package] name = "petr-playground" -version = "0.1.0" +version.workspace = true authors = ["Alex Hansen "] edition = "2018" rust-version = "1.57" +description = "website playground for the petr language" +license.workspace = true [lib] crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2.92" -petr-api = { path = "../petr-api", default-features = false, features = ["no_std"] } -stdlib = { path = "../stdlib" } +petr-api = { path = "../petr-api", default-features = false, features = ["no_std" ], version = "0.1.0" } +petr-stdlib = { path = "../petr-stdlib", version = "0.1.0" } [dev-dependencies] expect-test = "1.5.0" diff --git a/petr-playground/src/lib.rs b/petr-playground/src/lib.rs index 0d552d7..c6dc2cd 100644 --- a/petr-playground/src/lib.rs +++ b/petr-playground/src/lib.rs @@ -62,7 +62,7 @@ fn errors_to_html(e: &[String]) -> String { } fn compile_snippet(input: String) -> Result> { - let mut sources = stdlib::stdlib(); + let mut sources = petr_stdlib::stdlib(); sources.push(("snippet", &input)); let parser = petr_api::Parser::new(sources); let (ast, errs, interner, source_map) = parser.into_result(); diff --git a/petr-profiling/Cargo.toml b/petr-profiling/Cargo.toml index 4280d7a..c4273c0 100644 --- a/petr-profiling/Cargo.toml +++ b/petr-profiling/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "petr-profiling" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "tools for profiling the performance of the petr compiler" [dependencies] cli-table = "0.4" diff --git a/petr-resolve/Cargo.toml b/petr-resolve/Cargo.toml index 359ed84..e58495d 100644 --- a/petr-resolve/Cargo.toml +++ b/petr-resolve/Cargo.toml @@ -1,20 +1,26 @@ [package] name = "petr-resolve" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "resolution stage of the petr compiler" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] either = "1.13.0" -petr-ast = { path = "../petr-ast" } -petr-bind = { path = "../petr-bind" } -petr-utils = { path = "../petr-utils", optional = true } +petr-ast = { path = "../petr-ast", version = "0.1.0" } +petr-bind = { path = "../petr-bind", version = "0.1.0" } +petr-utils = { path = "../petr-utils", version = "0.1.0", optional = true } miette = { version = "5.10", features = ["fancy"] } thiserror = "1.0.61" [dev-dependencies] -petr-parse = { path = "../petr-parse" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } expect-test = "1.5.0" [features] diff --git a/petr-stdlib/Cargo.toml b/petr-stdlib/Cargo.toml new file mode 100644 index 0000000..baa4af5 --- /dev/null +++ b/petr-stdlib/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "petr-stdlib" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +description = "the petr language's standard library" +license.workspace = true + +[dependencies] diff --git a/stdlib/pete.toml b/petr-stdlib/pete.toml similarity index 85% rename from stdlib/pete.toml rename to petr-stdlib/pete.toml index 7a68f6e..e4bb5d7 100644 --- a/stdlib/pete.toml +++ b/petr-stdlib/pete.toml @@ -1,5 +1,5 @@ author = "Alex Hansen " -license = "MIT" +license.workspace = true name = "test_project" [formatter] diff --git a/stdlib/petr.lock b/petr-stdlib/petr.lock similarity index 100% rename from stdlib/petr.lock rename to petr-stdlib/petr.lock diff --git a/stdlib/src/io.pt b/petr-stdlib/src/io.pt similarity index 100% rename from stdlib/src/io.pt rename to petr-stdlib/src/io.pt diff --git a/stdlib/src/lib.rs b/petr-stdlib/src/lib.rs similarity index 100% rename from stdlib/src/lib.rs rename to petr-stdlib/src/lib.rs diff --git a/stdlib/src/mem.pt b/petr-stdlib/src/mem.pt similarity index 100% rename from stdlib/src/mem.pt rename to petr-stdlib/src/mem.pt diff --git a/stdlib/src/ops.pt b/petr-stdlib/src/ops.pt similarity index 100% rename from stdlib/src/ops.pt rename to petr-stdlib/src/ops.pt diff --git a/petr-typecheck/Cargo.toml b/petr-typecheck/Cargo.toml index e9db93f..99e1581 100644 --- a/petr-typecheck/Cargo.toml +++ b/petr-typecheck/Cargo.toml @@ -1,20 +1,26 @@ [package] name = "petr-typecheck" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "the typecheck stage of the petr compiler" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -petr-utils = { path = "../petr-utils", optional = true } -petr-resolve = { path = "../petr-resolve" } -petr-bind = { path = "../petr-bind" } +petr-utils = { path = "../petr-utils", version = "0.1.0", optional = true } +petr-resolve = { path = "../petr-resolve", version = "0.1.0" } +petr-bind = { path = "../petr-bind", version = "0.1.0" } miette = { version = "5.10", features = ["fancy"] } thiserror = "1.0.61" [dev-dependencies] -petr-parse = { path = "../petr-parse" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } expect-test = "1.5.0" [features] diff --git a/petr-typecheck/src/lib.rs b/petr-typecheck/src/lib.rs index b1e60d9..0b5baa0 100644 --- a/petr-typecheck/src/lib.rs +++ b/petr-typecheck/src/lib.rs @@ -959,7 +959,7 @@ impl TypeCheck for petr_resolve::FunctionCall { mod tests { use expect_test::{expect, Expect}; use petr_resolve::resolve_symbols; - use petr_utils::{render_error, SourceId}; + use petr_utils::render_error; use super::*; fn check( @@ -971,20 +971,17 @@ mod tests { let (ast, errs, interner, source_map) = parser.into_result(); if !errs.is_empty() { errs.into_iter().for_each(|err| eprintln!("{:?}", render_error(&source_map, err))); - panic!("fmt failed: code didn't parse"); + panic!("test failed: code didn't parse"); } let (errs, resolved) = resolve_symbols(ast, interner, Default::default()); assert!(errs.is_empty(), "can't typecheck: unresolved symbols"); let type_checker = TypeChecker::new(resolved); - let res = pretty_print_type_checker(type_checker, &source_map); + let res = pretty_print_type_checker(type_checker); expect.assert_eq(&res); } - fn pretty_print_type_checker( - type_checker: TypeChecker, - source_map: &IndexMap, - ) -> String { + fn pretty_print_type_checker(type_checker: TypeChecker) -> String { let mut s = String::new(); for (id, ty) in &type_checker.type_map { let text = match id { @@ -1023,8 +1020,7 @@ mod tests { if !type_checker.errors.is_empty() { s.push_str("\nErrors:\n"); for error in type_checker.errors { - let rendered = render_error(source_map, error); - s.push_str(&format!("{:?}\n", rendered)); + s.push_str(&format!("{:?}\n", error)); } } s @@ -1276,14 +1272,7 @@ mod tests { Errors: - × Failed to unify types: String, Boolean - ╭─[test:2:1] - 2 │ fn my_func() returns 'unit - 3 │ @puts(true) - · ──┬─ - · ╰── Failed to unify types: String, Boolean - ╰──── - + SpannedItem UnificationFailure(String, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(52), length: 4 } }] "#]], ); } @@ -1320,14 +1309,7 @@ mod tests { Errors: - × Failed to unify types: String, Boolean - ╭─[test:5:1] - 5 │ fn my_func() returns 'unit - 6 │ @puts(~bool_literal) - · ───────┬────── - · ╰── Failed to unify types: String, Boolean - ╰──── - + SpannedItem UnificationFailure(String, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(110), length: 14 } }] "#]], ); } @@ -1371,15 +1353,7 @@ mod tests { Errors: - × Failed to unify types: Integer, Boolean - ╭─[test:1:1] - 1 │ - 2 │ fn my_list() returns 'list [ 1, true ] - · ──┬── - · ╰── Failed to unify types: Integer, Boolean - 3 │ - ╰──── - + SpannedItem UnificationFailure(Integer, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(48), length: 5 } }] "#]], ); } @@ -1401,15 +1375,7 @@ mod tests { Errors: - × Function add takes 2 arguments, but got 1 arguments. - ╭─[test:3:1] - 3 │ - 4 │ fn add_five(a in 'int) returns 'int ~add(5) - · ────┬─── - · ╰── Function add takes 2 arguments, but got 1 arguments. - 5 │ - ╰──── - + SpannedItem ArgumentCountMismatch { function: "add", expected: 2, got: 1 } [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(113), length: 8 } }] "#]], ); } diff --git a/petr-utils/Cargo.lock b/petr-utils/Cargo.lock index 40d5d68..8a7da09 100644 --- a/petr-utils/Cargo.lock +++ b/petr-utils/Cargo.lock @@ -220,7 +220,7 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "petr-utils" -version = "0.1.0" +version.workspace = true dependencies = [ "miette", ] diff --git a/petr-utils/Cargo.toml b/petr-utils/Cargo.toml index 0c89998..5d4629e 100644 --- a/petr-utils/Cargo.toml +++ b/petr-utils/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "petr-utils" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "common utilities for the petr compiler and tooling" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/petr-vm/Cargo.toml b/petr-vm/Cargo.toml index 0abba4b..30e4d13 100644 --- a/petr-vm/Cargo.toml +++ b/petr-vm/Cargo.toml @@ -1,19 +1,25 @@ [package] name = "petr-vm" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +license.workspace = true +description = "a basic VM for running and debugging petr IR" [dependencies] -petr-ir = { path = "../petr-ir" } -petr-utils = { path = "../petr-utils", optional = true } +petr-ir = { path = "../petr-ir", version = "0.1.0" } +petr-utils = { path = "../petr-utils", version = "0.1.0", optional = true } thiserror = "1.0.61" [dev-dependencies] -petr-parse = { path = "../petr-parse" } +petr-parse = { path = "../petr-parse", version = "0.1.0" } expect-test = "1.5.0" -petr-resolve = { path = "../petr-resolve" } -petr-typecheck = { path = "../petr-typecheck" } -stdlib = { path = "../stdlib" } +petr-resolve = { path = "../petr-resolve", version = "0.1.0" } +petr-typecheck = { path = "../petr-typecheck", version = "0.1.0" } +petr-stdlib = { path = "../petr-stdlib", version = "0.1.0" } [features] debug = ["petr-utils/debug"] diff --git a/petr-vm/src/lib.rs b/petr-vm/src/lib.rs index 3f30fbb..9862829 100644 Binary files a/petr-vm/src/lib.rs and b/petr-vm/src/lib.rs differ diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml deleted file mode 100644 index c4c0e7f..0000000 --- a/stdlib/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "stdlib" -version = "0.1.0" -edition = "2021" - -[dependencies]