From 3304a9996eef11fc22e669a6bd3524115db1af3a Mon Sep 17 00:00:00 2001 From: Champii Date: Mon, 6 Jun 2022 14:55:28 +0200 Subject: [PATCH 1/4] No arg call (#100) * Add no argument call with `!` --- .github/templates/README.md | 32 +++++++++++++-------------- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 44 ++++++++++++++++++------------------- src/lib/parser/mod.rs | 1 + std/src/externs.rk | 2 +- std/src/fs.rk | 2 +- std/src/functor.rk | 2 +- std/src/print.rk | 2 +- std/src/show.rk | 2 +- std/src/vec.rk | 4 ++-- 11 files changed, 48 insertions(+), 47 deletions(-) diff --git a/.github/templates/README.md b/.github/templates/README.md index f7d3851e..8716e729 100644 --- a/.github/templates/README.md +++ b/.github/templates/README.md @@ -107,7 +107,7 @@ fact a = then 1 else a * fact (a - 1) -main = fact(4).print() +main = fact(4).print! ``` Assuming that you built Rock and put its binary in your PATH: @@ -129,9 +129,9 @@ Note that you currently must be at the project root to run the compiler. (i.e. i id a = a main = - id(1).print() - id(2.2).print() - id("Test").print() + id(1).print! + id(2.2).print! + id("Test").print! ``` Prints @@ -168,7 +168,7 @@ infix |> 1 f a = a + 2 -main = (4 |> f).print() +main = (4 |> f).print! ``` ``` sh @@ -190,14 +190,14 @@ trait ToString a tostring :: a -> String impl ToString Int64 - @tostring = @show() + @tostring = @show! impl ToString Float64 - @tostring = @show() + @tostring = @show! main = - (33).tostring().print() - (42.42).tostring().print() + (33).tostring!.print! + (42.42).tostring!.print! ``` ``` sh @@ -222,7 +222,7 @@ impl Player main = let player = Player::new 1 - player.getlevel().print() + player.getlevel!.print! ``` ``` sh @@ -238,17 +238,17 @@ struct Player name :: String impl Show Player - @show = @name + "(" + @level.show() + ")" + @show = @name + "(" + @level.show! + ")" impl Print Player - @print = printl self.show() + @print = printl self.show! main = let player = Player level: 42 name: "MyName" - player.print() + player.print! ``` ``` sh @@ -258,7 +258,7 @@ MyName Note that the `printl` method is defined in the stdlib as ```haskell -printl a = c_puts a.show() +printl a = c_puts a.show! ``` with `c_puts` being the `libc` `puts` @@ -277,7 +277,7 @@ mod foo use foo::bar -main = bar(1).print() +main = bar(1).print! ``` ```sh @@ -288,7 +288,7 @@ $ rock run Note that we could have skiped the `use foo::bar` if we wrote -`main = foo::bar(1).print()` +`main = foo::bar(1).print!` ## REPL diff --git a/Cargo.lock b/Cargo.lock index 6bdec62b..639c5718 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,7 +473,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rock" -version = "0.2.4-self-arg" +version = "0.2.4-develop" dependencies = [ "bincode", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 41f3ee20..764df794 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rock" -version = "0.2.4-develop" +version = "0.2.4-no-arg-call" authors = ["champii "] edition = "2018" diff --git a/README.md b/README.md index 77945ad4..a191dd5b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Rock v0.2.4-develop +# Rock v0.2.4-no-arg-call -[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=develop)](https://github.com/Champii/Rock/actions/workflows/rust.yml) +[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=no_arg_call)](https://github.com/Champii/Rock/actions/workflows/rust.yml) Little language made with Rust and LLVM. @@ -12,7 +12,7 @@ No to be taken seriously (yet) ## Index -- [Rock v0.2.4-develop](#rock-v0.2.4-develop) +- [Rock v0.2.4-no-arg-call](#rock-v0.2.4-no-arg-call) - [Index](#index) - [Features](#features) - [Install](#install) @@ -58,10 +58,10 @@ You will need `clang` somewhere in your $PATH Linux x86_64 only -[Rock v0.2.4-develop](https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock) (Tested on arch, btw) +[Rock v0.2.4-no-arg-call](https://github.com/Champii/Rock/releases/download/v0.2.4-no-arg-call/rock) (Tested on arch, btw) ``` sh -wget https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock +wget https://github.com/Champii/Rock/releases/download/v0.2.4-no-arg-call/rock chmod +x rock ./rock -V ``` @@ -107,7 +107,7 @@ fact a = then 1 else a * fact (a - 1) -main = fact(4).print() +main = fact(4).print! ``` Assuming that you built Rock and put its binary in your PATH: @@ -129,9 +129,9 @@ Note that you currently must be at the project root to run the compiler. (i.e. i id a = a main = - id(1).print() - id(2.2).print() - id("Test").print() + id(1).print! + id(2.2).print! + id("Test").print! ``` Prints @@ -168,7 +168,7 @@ infix |> 1 f a = a + 2 -main = (4 |> f).print() +main = (4 |> f).print! ``` ``` sh @@ -190,14 +190,14 @@ trait ToString a tostring :: a -> String impl ToString Int64 - @tostring = @show() + @tostring = @show! impl ToString Float64 - @tostring = @show() + @tostring = @show! main = - (33).tostring().print() - (42.42).tostring().print() + (33).tostring!.print! + (42.42).tostring!.print! ``` ``` sh @@ -222,7 +222,7 @@ impl Player main = let player = Player::new 1 - player.getlevel().print() + player.getlevel!.print! ``` ``` sh @@ -238,17 +238,17 @@ struct Player name :: String impl Show Player - @show = @name + "(" + @level.show() + ")" + @show = @name + "(" + @level.show! + ")" impl Print Player - @print = printl self.show() + @print = printl self.show! main = let player = Player level: 42 name: "MyName" - player.print() + player.print! ``` ``` sh @@ -258,7 +258,7 @@ MyName Note that the `printl` method is defined in the stdlib as ```haskell -printl a = c_puts a.show() +printl a = c_puts a.show! ``` with `c_puts` being the `libc` `puts` @@ -277,7 +277,7 @@ mod foo use foo::bar -main = bar(1).print() +main = bar(1).print! ``` ```sh @@ -288,7 +288,7 @@ $ rock run Note that we could have skiped the `use foo::bar` if we wrote -`main = foo::bar(1).print()` +`main = foo::bar(1).print!` ## REPL @@ -310,7 +310,7 @@ rock --repl ``` ``` sh -Rock: v0.2.4-develop +Rock: v0.2.4-no-arg-call ---- Type ':?' for help diff --git a/src/lib/parser/mod.rs b/src/lib/parser/mod.rs index 4f803527..130fe032 100644 --- a/src/lib/parser/mod.rs +++ b/src/lib/parser/mod.rs @@ -820,6 +820,7 @@ pub fn parse_secondary(input: Parser) -> Res { pub fn parse_arguments(input: Parser) -> Res { alt(( + map(tag("!"), |_| vec![]), map( tuple(( terminated(tag("("), space0), diff --git a/std/src/externs.rk b/std/src/externs.rk index 7d4ab11e..6d749d62 100644 --- a/std/src/externs.rk +++ b/std/src/externs.rk @@ -16,7 +16,7 @@ c_strncpy dest src len = strncpy dest, src, len _shutup_warnings = c_strncpy "a", "b", 1 c_write 0, "1", 0 - _shutup_warnings() + _shutup_warnings! extern sprintf :: String -> String -> Int64 -> Int64 c_sprintf dest format i = sprintf dest, format, i diff --git a/std/src/fs.rk b/std/src/fs.rk index f537b485..37252054 100644 --- a/std/src/fs.rk +++ b/std/src/fs.rk @@ -16,7 +16,7 @@ struct File impl Show File @show = - "File { fd: " + @fd.show() + ", path: " + @path + " }" + "File { fd: " + @fd.show! + ", path: " + @path + " }" impl File open p = diff --git a/std/src/functor.rk b/std/src/functor.rk index bdd97f93..5430bb04 100644 --- a/std/src/functor.rk +++ b/std/src/functor.rk @@ -19,4 +19,4 @@ foreach f arr = _shut_up_warnings = map 0, 0 foreach 0, 0 - _shut_up_warnings() + _shut_up_warnings! diff --git a/std/src/print.rk b/std/src/print.rk index 1651b81c..20117b2c 100644 --- a/std/src/print.rk +++ b/std/src/print.rk @@ -5,7 +5,7 @@ use super::num::(*) # there is a bug here if a method exists with the same name in the scope # of the module (like Print::print and print) -printl a = c_puts a.show() +printl a = c_puts a.show! trait Print a print :: a -> a diff --git a/std/src/show.rk b/std/src/show.rk index 6418528f..22c0c5a2 100644 --- a/std/src/show.rk +++ b/std/src/show.rk @@ -41,7 +41,7 @@ show_arr a = let i = 0 let len = ~Len a a while i < len - c_strcat s, a[i].show() + c_strcat s, a[i].show! c_strcat s, ", " i = i + 1 c_strcat s, "]" diff --git a/std/src/vec.rk b/std/src/vec.rk index effacdd1..699bc7f3 100644 --- a/std/src/vec.rk +++ b/std/src/vec.rk @@ -10,7 +10,7 @@ struct Vec len :: Int64 impl Show Vec - @show = @len.show() + @show = @len.show! impl Vec new = @@ -31,6 +31,6 @@ impl Vec d[@len] = item @len = @len + 1 if @len == @cap - then @realloc() + then @realloc! else 0 From 0aca6b3086074c7ca434fcfe8c0669c58d657005 Mon Sep 17 00:00:00 2001 From: Champii Date: Mon, 6 Jun 2022 12:55:46 +0000 Subject: [PATCH 2/4] Generated files for new version --- Cargo.toml | 2 +- README.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 764df794..41f3ee20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rock" -version = "0.2.4-no-arg-call" +version = "0.2.4-develop" authors = ["champii "] edition = "2018" diff --git a/README.md b/README.md index a191dd5b..dca52125 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Rock v0.2.4-no-arg-call +# Rock v0.2.4-develop -[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=no_arg_call)](https://github.com/Champii/Rock/actions/workflows/rust.yml) +[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=develop)](https://github.com/Champii/Rock/actions/workflows/rust.yml) Little language made with Rust and LLVM. @@ -12,7 +12,7 @@ No to be taken seriously (yet) ## Index -- [Rock v0.2.4-no-arg-call](#rock-v0.2.4-no-arg-call) +- [Rock v0.2.4-develop](#rock-v0.2.4-develop) - [Index](#index) - [Features](#features) - [Install](#install) @@ -58,10 +58,10 @@ You will need `clang` somewhere in your $PATH Linux x86_64 only -[Rock v0.2.4-no-arg-call](https://github.com/Champii/Rock/releases/download/v0.2.4-no-arg-call/rock) (Tested on arch, btw) +[Rock v0.2.4-develop](https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock) (Tested on arch, btw) ``` sh -wget https://github.com/Champii/Rock/releases/download/v0.2.4-no-arg-call/rock +wget https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock chmod +x rock ./rock -V ``` @@ -310,7 +310,7 @@ rock --repl ``` ``` sh -Rock: v0.2.4-no-arg-call +Rock: v0.2.4-develop ---- Type ':?' for help From 6fc5effacdecf6a02d7e14196d24caf014311237 Mon Sep 17 00:00:00 2001 From: Champii Date: Thu, 9 Jun 2022 01:50:50 +0200 Subject: [PATCH 3/4] Spaced dot (#101) * Add no argument call with `!` * Allow spaced dot * Update vulnerable cargo dependancies * Fixed monomorphic call fail on trait method --- .github/templates/README.md | 22 ++++++------ Cargo.lock | 18 +++++----- Cargo.toml | 2 +- README.md | 34 +++++++++---------- src/lib/ast_lowering/ast_lowering_context.rs | 1 + src/lib/infer/monomorphize/monomorphizer.rs | 24 ++++++++++--- src/lib/parser/mod.rs | 5 +-- src/lib/resolver/resolve_ctx.rs | 1 + src/lib/testcases/basic/spaced_dot/main.rk | 11 ++++++ .../testcases/basic/spaced_dot/main.rk.out | 1 + .../testcases/basic/spaced_dot/main.rk.stdout | 0 .../testcases/basic/trait_monomorph/main.rk | 3 +- src/lib/tests.rs | 4 +++ std/src/print.rk | 3 +- 14 files changed, 78 insertions(+), 51 deletions(-) create mode 100644 src/lib/testcases/basic/spaced_dot/main.rk create mode 100644 src/lib/testcases/basic/spaced_dot/main.rk.out create mode 100644 src/lib/testcases/basic/spaced_dot/main.rk.stdout diff --git a/.github/templates/README.md b/.github/templates/README.md index 8716e729..c57b8540 100644 --- a/.github/templates/README.md +++ b/.github/templates/README.md @@ -5,11 +5,10 @@ Little language made with Rust and LLVM. Aim to follow the enforced safeness of the Rust model with a borrow checker (Soon™) and achieve high native performances thanks to LLVM. -Rock is highly inspired from Livescript and Rust, and will also borrow (pun intended) some features from Crystal, from functional languages like Haskell, and even from Rust itself. +Rock is highly inspired from [Livescript](https://livescript.net/), [Haskell](https://www.haskell.org/) and [Rust](https://www.rust-lang.org/) No to be taken seriously (yet) - ## Index - [Rock {version}](#rock-{version}) @@ -107,7 +106,7 @@ fact a = then 1 else a * fact (a - 1) -main = fact(4).print! +main = fact 4 .print! ``` Assuming that you built Rock and put its binary in your PATH: @@ -129,9 +128,9 @@ Note that you currently must be at the project root to run the compiler. (i.e. i id a = a main = - id(1).print! - id(2.2).print! - id("Test").print! + id 1 .print! + id 2.2 .print! + id "Test" .print! ``` Prints @@ -221,8 +220,7 @@ impl Player @getlevel = @level main = - let player = Player::new 1 - player.getlevel!.print! + Player::new 1 .getlevel!.print! ``` ``` sh @@ -241,7 +239,7 @@ impl Show Player @show = @name + "(" + @level.show! + ")" impl Print Player - @print = printl self.show! + @print = printl @show! main = let player = Player @@ -253,7 +251,7 @@ main = ``` sh $ rock run -MyName +MyName(42) ``` Note that the `printl` method is defined in the stdlib as @@ -277,7 +275,7 @@ mod foo use foo::bar -main = bar(1).print! +main = bar 1 .print! ``` ```sh @@ -288,7 +286,7 @@ $ rock run Note that we could have skiped the `use foo::bar` if we wrote -`main = foo::bar(1).print!` +`main = foo::bar 1 .print!` ## REPL diff --git a/Cargo.lock b/Cargo.lock index 639c5718..fdea8f0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -322,9 +322,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" dependencies = [ "aho-corasick", "memchr", @@ -467,13 +467,13 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" [[package]] name = "rock" -version = "0.2.4-develop" +version = "0.2.4-spaced-dot" dependencies = [ "bincode", "bitflags", @@ -497,9 +497,9 @@ dependencies = [ [[package]] name = "rustyline" -version = "9.0.0" +version = "9.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790487c3881a63489ae77126f57048b42d62d3b2bafbf37453ea19eedb6340d6" +checksum = "db7826789c0e25614b03e5a54a0717a86f9ff6e6e5247f92b369472869320039" dependencies = [ "bitflags", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 41f3ee20..ea4e113a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rock" -version = "0.2.4-develop" +version = "0.2.4-spaced-dot" authors = ["champii "] edition = "2018" diff --git a/README.md b/README.md index dca52125..90855a55 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ -# Rock v0.2.4-develop +# Rock v0.2.4-spaced-dot -[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=develop)](https://github.com/Champii/Rock/actions/workflows/rust.yml) +[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=spaced_dot)](https://github.com/Champii/Rock/actions/workflows/rust.yml) Little language made with Rust and LLVM. Aim to follow the enforced safeness of the Rust model with a borrow checker (Soon™) and achieve high native performances thanks to LLVM. -Rock is highly inspired from Livescript and Rust, and will also borrow (pun intended) some features from Crystal, from functional languages like Haskell, and even from Rust itself. +Rock is highly inspired from [Livescript](https://livescript.net/), [Haskell](https://www.haskell.org/) and [Rust](https://www.rust-lang.org/) No to be taken seriously (yet) - ## Index -- [Rock v0.2.4-develop](#rock-v0.2.4-develop) +- [Rock v0.2.4-spaced-dot](#rock-v0.2.4-spaced-dot) - [Index](#index) - [Features](#features) - [Install](#install) @@ -58,10 +57,10 @@ You will need `clang` somewhere in your $PATH Linux x86_64 only -[Rock v0.2.4-develop](https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock) (Tested on arch, btw) +[Rock v0.2.4-spaced-dot](https://github.com/Champii/Rock/releases/download/v0.2.4-spaced-dot/rock) (Tested on arch, btw) ``` sh -wget https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock +wget https://github.com/Champii/Rock/releases/download/v0.2.4-spaced-dot/rock chmod +x rock ./rock -V ``` @@ -107,7 +106,7 @@ fact a = then 1 else a * fact (a - 1) -main = fact(4).print! +main = fact 4 .print! ``` Assuming that you built Rock and put its binary in your PATH: @@ -129,9 +128,9 @@ Note that you currently must be at the project root to run the compiler. (i.e. i id a = a main = - id(1).print! - id(2.2).print! - id("Test").print! + id 1 .print! + id 2.2 .print! + id "Test" .print! ``` Prints @@ -221,8 +220,7 @@ impl Player @getlevel = @level main = - let player = Player::new 1 - player.getlevel!.print! + Player::new 1 .getlevel!.print! ``` ``` sh @@ -241,7 +239,7 @@ impl Show Player @show = @name + "(" + @level.show! + ")" impl Print Player - @print = printl self.show! + @print = printl @show! main = let player = Player @@ -253,7 +251,7 @@ main = ``` sh $ rock run -MyName +MyName(42) ``` Note that the `printl` method is defined in the stdlib as @@ -277,7 +275,7 @@ mod foo use foo::bar -main = bar(1).print! +main = bar 1 .print! ``` ```sh @@ -288,7 +286,7 @@ $ rock run Note that we could have skiped the `use foo::bar` if we wrote -`main = foo::bar(1).print!` +`main = foo::bar 1 .print!` ## REPL @@ -310,7 +308,7 @@ rock --repl ``` ``` sh -Rock: v0.2.4-develop +Rock: v0.2.4-spaced-dot ---- Type ':?' for help diff --git a/src/lib/ast_lowering/ast_lowering_context.rs b/src/lib/ast_lowering/ast_lowering_context.rs index aa17269f..84175cab 100644 --- a/src/lib/ast_lowering/ast_lowering_context.rs +++ b/src/lib/ast_lowering/ast_lowering_context.rs @@ -147,6 +147,7 @@ impl AstLoweringContext { .clone(); let type_sig = type_sig.apply_forall_types(&r#trait.types, &i.types); + type_sig } else { f.signature.clone() diff --git a/src/lib/infer/monomorphize/monomorphizer.rs b/src/lib/infer/monomorphize/monomorphizer.rs index c313495b..190c9d95 100644 --- a/src/lib/infer/monomorphize/monomorphizer.rs +++ b/src/lib/infer/monomorphize/monomorphizer.rs @@ -53,9 +53,6 @@ impl<'a> Monomorphizer<'a> { } } - // The collect here is needed as we NEED the generated_fn_hir_id.insert() side effect - // and the for version would be too messy - #[allow(clippy::needless_collect)] let fresh_top_levels_flat = self .get_fn_envs_pairs() .into_iter() @@ -287,7 +284,7 @@ impl<'a, 'b> VisitorMut<'a> for Monomorphizer<'b> { .get(&self.resolve(&old_fc_op).unwrap()) .unwrap() { - HirNode::FunctionDecl(_) => { + HirNode::FunctionDecl(f) => { if let Some(generated_fn) = self.generated_fn_hir_id.get(&( self.resolve_rec(&old_fc_op).unwrap(), fc.to_func_type(&self.root.node_types), @@ -295,7 +292,24 @@ impl<'a, 'b> VisitorMut<'a> for Monomorphizer<'b> { self.new_resolutions .insert(fc.op.get_hir_id(), generated_fn.clone()); } else { - panic!("BUG: Cannot find function from signature"); + // This is a dirty duplicate of the `Prototype` branch below + if let Some(f) = self.root.get_trait_method( + (*f.name).clone(), + &fc.to_func_type(&self.root.node_types), + ) { + if let Some(trans_res) = self.trans_resolutions.get(&f.hir_id) { + self.new_resolutions.insert(fc.op.get_hir_id(), trans_res); + } else { + panic!( + "NO TRANS RES FOR TRAIT {:#?} {:#?} {:#?}", + self.trans_resolutions, + fc.op.get_hir_id(), + f.hir_id, + ); + } + } else { + } + // panic!("BUG: Cannot find function from signature"); } self.trans_resolutions.remove(&old_fc_op); diff --git a/src/lib/parser/mod.rs b/src/lib/parser/mod.rs index 130fe032..d9212198 100644 --- a/src/lib/parser/mod.rs +++ b/src/lib/parser/mod.rs @@ -833,14 +833,15 @@ pub fn parse_arguments(input: Parser) -> Res { tuple(( space0, separated_list1(tuple((space0, tag(","), space0)), parse_argument), + space0, )), - |(_, args)| args, + |(_, args, _)| args, ), ))(input) } pub fn parse_argument(input: Parser) -> Res { - map(parse_unary, Argument::new)(input) + map(parse_unary, |arg| Argument::new(arg))(input) } pub fn parse_indice(input: Parser) -> Res> { diff --git a/src/lib/resolver/resolve_ctx.rs b/src/lib/resolver/resolve_ctx.rs index 0070c28a..3c6714cc 100644 --- a/src/lib/resolver/resolve_ctx.rs +++ b/src/lib/resolver/resolve_ctx.rs @@ -193,6 +193,7 @@ impl<'a> Visitor<'a> for ResolveCtx<'a> { self.pop_scope(); } + fn visit_impl(&mut self, impl_: &'a Impl) { self.push_scope(); self.import_struct_scope(Identifier::new(impl_.name.get_name(), 0)); diff --git a/src/lib/testcases/basic/spaced_dot/main.rk b/src/lib/testcases/basic/spaced_dot/main.rk new file mode 100644 index 00000000..4e4b7387 --- /dev/null +++ b/src/lib/testcases/basic/spaced_dot/main.rk @@ -0,0 +1,11 @@ +struct Toto + lol :: Int64 + +impl Toto + new x = Toto + lol: x + @me = @ + @get a = @lol + +main = + Toto::new 42 .me!.me!.get 2 diff --git a/src/lib/testcases/basic/spaced_dot/main.rk.out b/src/lib/testcases/basic/spaced_dot/main.rk.out new file mode 100644 index 00000000..f70d7bba --- /dev/null +++ b/src/lib/testcases/basic/spaced_dot/main.rk.out @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/src/lib/testcases/basic/spaced_dot/main.rk.stdout b/src/lib/testcases/basic/spaced_dot/main.rk.stdout new file mode 100644 index 00000000..e69de29b diff --git a/src/lib/testcases/basic/trait_monomorph/main.rk b/src/lib/testcases/basic/trait_monomorph/main.rk index 8664c632..03a1b3a5 100644 --- a/src/lib/testcases/basic/trait_monomorph/main.rk +++ b/src/lib/testcases/basic/trait_monomorph/main.rk @@ -7,8 +7,7 @@ impl Toto Int64 impl Toto Bool @toto = "true" -# print a = a.toto() -print a = Toto::toto a +print a = a.toto() main = print true diff --git a/src/lib/tests.rs b/src/lib/tests.rs index f1b20d22..bb92f7ae 100644 --- a/src/lib/tests.rs +++ b/src/lib/tests.rs @@ -74,6 +74,10 @@ fn testcases_basic_extern_main() { run("testcases/basic/extern/main.rk", include_str!("testcases/basic/extern/main.rk"), include_str!("testcases/basic/extern/main.rk.out"), include_str!("testcases/basic/extern/main.rk.stdout")); } #[test] +fn testcases_basic_spaced_dot_main() { + run("testcases/basic/spaced_dot/main.rk", include_str!("testcases/basic/spaced_dot/main.rk"), include_str!("testcases/basic/spaced_dot/main.rk.out"), include_str!("testcases/basic/spaced_dot/main.rk.stdout")); +} +#[test] fn testcases_basic_monomorph_in_trait_main() { run("testcases/basic/monomorph_in_trait/main.rk", include_str!("testcases/basic/monomorph_in_trait/main.rk"), include_str!("testcases/basic/monomorph_in_trait/main.rk.out"), include_str!("testcases/basic/monomorph_in_trait/main.rk.stdout")); } diff --git a/std/src/print.rk b/std/src/print.rk index 20117b2c..e5f44524 100644 --- a/std/src/print.rk +++ b/std/src/print.rk @@ -8,7 +8,7 @@ use super::num::(*) printl a = c_puts a.show! trait Print a - print :: a -> a + print :: a -> Int64 # Here we would need generic impl impl Print Bool @@ -23,5 +23,4 @@ impl Print Float64 impl Print String @print = printl @ - use Print::(*) From e7d4979e1e6d816e1efdf335bb0bed82eccc134d Mon Sep 17 00:00:00 2001 From: Champii Date: Wed, 8 Jun 2022 23:51:03 +0000 Subject: [PATCH 4/4] Generated files for new version --- Cargo.toml | 2 +- README.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ea4e113a..41f3ee20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rock" -version = "0.2.4-spaced-dot" +version = "0.2.4-develop" authors = ["champii "] edition = "2018" diff --git a/README.md b/README.md index 90855a55..e0638343 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Rock v0.2.4-spaced-dot +# Rock v0.2.4-develop -[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=spaced_dot)](https://github.com/Champii/Rock/actions/workflows/rust.yml) +[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=develop)](https://github.com/Champii/Rock/actions/workflows/rust.yml) Little language made with Rust and LLVM. @@ -11,7 +11,7 @@ No to be taken seriously (yet) ## Index -- [Rock v0.2.4-spaced-dot](#rock-v0.2.4-spaced-dot) +- [Rock v0.2.4-develop](#rock-v0.2.4-develop) - [Index](#index) - [Features](#features) - [Install](#install) @@ -57,10 +57,10 @@ You will need `clang` somewhere in your $PATH Linux x86_64 only -[Rock v0.2.4-spaced-dot](https://github.com/Champii/Rock/releases/download/v0.2.4-spaced-dot/rock) (Tested on arch, btw) +[Rock v0.2.4-develop](https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock) (Tested on arch, btw) ``` sh -wget https://github.com/Champii/Rock/releases/download/v0.2.4-spaced-dot/rock +wget https://github.com/Champii/Rock/releases/download/v0.2.4-develop/rock chmod +x rock ./rock -V ``` @@ -308,7 +308,7 @@ rock --repl ``` ``` sh -Rock: v0.2.4-spaced-dot +Rock: v0.2.4-develop ---- Type ':?' for help