From 448babe8090c2bcf177c23efd2257a926a1d07f7 Mon Sep 17 00:00:00 2001 From: Cody Date: Tue, 25 Apr 2023 19:37:44 -0500 Subject: Added Nix package --- flake.nix | 70 ++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 23 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 77fc725..ce3b001 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,6 @@ { + description = "slothlang"; + inputs = { nixpkgs.url = "github:nixos/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; @@ -10,29 +12,51 @@ }; outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }: - flake-utils.lib.eachSystem - [ "x86_64-linux" ] - (system: - let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { - inherit system overlays; - }; - in - rec - { - devShell = pkgs.mkShell rec { - buildInputs = with pkgs; [ - (rust-bin.nightly."2023-02-10".default.override { - extensions = [ "rust-src" "rust-analyzer" ]; - targets = [ "wasm32-unknown-unknown" ]; - }) + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + rustStable = pkgs.rust-bin.stable.latest.default; + rustNightly = pkgs.rust-bin.nightly."2023-02-10".default; + + rustPlatform = pkgs.makeRustPlatform { + cargo = rustStable; + rustc = rustStable; + }; + in + with pkgs; + { + packages.default = rustPlatform.buildRustPackage rec { + pname = "sloth"; + version = "0.1.0"; + src = ./.; + + # FIXME: Tests do not run in release mode + checkType = "debug"; + cargoLock = { + lockFile = ./Cargo.lock; + }; - cargo-deny - cargo-release - ]; + meta = with lib; { + description = "The Sloth programming language"; + homepage = "https://slothlang.tech"; + license = with licenses; [ mit asl20 ]; + }; + }; + devShells.default = mkShell { + buildInputs = [ + (rustNightly.override { + extensions = [ "rust-src" "rust-analyzer" ]; + targets = [ "wasm32-unknown-unknown" ]; + }) - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; - }; - }); + cargo-deny + cargo-release + ]; + }; + } + ); } -- cgit v1.2.3 From e92ee3d43d9101e34ab6727441dc9567b8f80d72 Mon Sep 17 00:00:00 2001 From: Cody Date: Wed, 24 May 2023 00:18:31 -0500 Subject: Some changes --- Cargo.lock | 9 +++++++-- Cargo.toml | 1 + crates/sloth/Cargo.toml | 1 + crates/sloth/src/main.rs | 2 +- crates/sloth/src/parser/ast.rs | 5 +++++ crates/sloth/src/parser/expr.rs | 2 +- crates/sloth_asm/Cargo.toml | 8 ++++++++ crates/sloth_asm/src/lib.rs | 1 + flake.nix | 1 + 9 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 crates/sloth_asm/Cargo.toml create mode 100644 crates/sloth_asm/src/lib.rs (limited to 'flake.nix') diff --git a/Cargo.lock b/Cargo.lock index b7ccbe0..c46664e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.141" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "once_cell" @@ -111,9 +111,14 @@ name = "sloth" version = "0.1.0" dependencies = [ "itertools", + "libc", "thiserror", ] +[[package]] +name = "sloth_asm" +version = "0.1.0" + [[package]] name = "sloth_bytecode" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 57e0bc4..118519e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "crates/sloth", + "crates/sloth_asm", "crates/sloth_bytecode", "crates/sloth_vm", ] diff --git a/crates/sloth/Cargo.toml b/crates/sloth/Cargo.toml index 2ee6919..1b7a9fc 100644 --- a/crates/sloth/Cargo.toml +++ b/crates/sloth/Cargo.toml @@ -7,4 +7,5 @@ edition.workspace = true [dependencies] itertools = "0.10.5" +libc = "0.2.142" thiserror = "1.0.40" diff --git a/crates/sloth/src/main.rs b/crates/sloth/src/main.rs index 0eb4c24..8fab058 100644 --- a/crates/sloth/src/main.rs +++ b/crates/sloth/src/main.rs @@ -38,5 +38,5 @@ fn main() { // println!("{:#?}", parser); let parsed = &parser.parse(); - println!("{:#?}", parsed); + println!("{parsed:#?}"); } diff --git a/crates/sloth/src/parser/ast.rs b/crates/sloth/src/parser/ast.rs index 3c8cdeb..12dad13 100644 --- a/crates/sloth/src/parser/ast.rs +++ b/crates/sloth/src/parser/ast.rs @@ -24,6 +24,7 @@ pub enum BinaryOp { LogOr, Range, } + #[derive(Debug, PartialEq)] pub enum UnaryOp { Not, @@ -31,6 +32,7 @@ pub enum UnaryOp { BWComp, } + #[derive(Debug, PartialEq)] pub enum Literal { Integer(i128), @@ -41,6 +43,7 @@ pub enum Literal { Regex(String), List(Vec), } + #[derive(Debug, PartialEq)] pub enum Expr { Grouping(Box), @@ -61,11 +64,13 @@ pub enum Expr { Literal(Literal), Lambda, // TODO: Lambda } + #[derive(PartialEq, Debug)] pub struct FuncArgs { pub name: String, pub typ: Option, } + #[derive(PartialEq, Debug)] pub enum Stmt { ExprStmt(Expr), diff --git a/crates/sloth/src/parser/expr.rs b/crates/sloth/src/parser/expr.rs index ad35d20..8036552 100644 --- a/crates/sloth/src/parser/expr.rs +++ b/crates/sloth/src/parser/expr.rs @@ -156,7 +156,7 @@ impl<'a> AstParser<'a> { // Binary expressions in order of precedence from lowest to highest. binary_expr!(logical_or , logical_and , (TokenType::PipePipe)); binary_expr!(logical_and , range , (TokenType::AmpAmp)); - binary_expr!(range , equality , (TokenType::DotDot)); + binary_expr!(range , equality , (TokenType::DotDot)); binary_expr!(equality , comparison , (TokenType::BangEq | TokenType::EqEq)); binary_expr!(comparison , bitwise_shifting, (TokenType::Lt | TokenType::Gt | TokenType::LtEq | TokenType::GtEq)); binary_expr!(bitwise_shifting, additive , (TokenType::LtLt | TokenType::GtGt)); diff --git a/crates/sloth_asm/Cargo.toml b/crates/sloth_asm/Cargo.toml new file mode 100644 index 0000000..b3ae934 --- /dev/null +++ b/crates/sloth_asm/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "sloth_asm" + +license.workspace = true +version.workspace = true +edition.workspace = true + +[dependencies] diff --git a/crates/sloth_asm/src/lib.rs b/crates/sloth_asm/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/crates/sloth_asm/src/lib.rs @@ -0,0 +1 @@ + diff --git a/flake.nix b/flake.nix index ce3b001..4223f11 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,7 @@ targets = [ "wasm32-unknown-unknown" ]; }) + cargo-watch cargo-deny cargo-release ]; -- cgit v1.2.3