Skip to content

Commit 9dc0729

Browse files
committed
v0.2.1
2 parents ffcd530 + 5cef8f3 commit 9dc0729

36 files changed

+162
-389
lines changed

.github/templates/README.md

-22
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,9 @@ mkdir -P factorial/src && cd factorial
8282

8383
Add some files like this:
8484

85-
- Copy all the stdlib files from [std/src/\*.rk](https://github.com/Champii/Rock/blob/master/std/src) into `factorial/src/`
86-
8785
- Create a `factorial/src/main.rk` file:
8886

8987
```haskell
90-
mod lib
91-
92-
use lib::prelude::(*)
93-
9488
fact a =
9589
if a <= 1
9690
then 1
@@ -121,10 +115,6 @@ Note that you currently must be at the project root to run the compiler. (i.e. i
121115

122116

123117
``` haskell
124-
mod lib
125-
126-
use lib::prelude::(*)
127-
128118
id a = a
129119

130120
main =
@@ -148,10 +138,6 @@ Test
148138
### Custom infix operator
149139

150140
``` haskell
151-
mod lib
152-
153-
use lib::prelude::(*)
154-
155141
infix |> 1
156142
|> x f = f x
157143

@@ -171,10 +157,6 @@ Prints `6`
171157
This `trait ToString` is redondant with the `trait Show` implemented in the lib, and serves as a demonstration only
172158

173159
``` haskell
174-
mod lib
175-
176-
use lib::prelude::(*)
177-
178160
trait ToString a
179161
toString :: a -> String
180162

@@ -204,10 +186,6 @@ Prints
204186
### Struct instance and Show implementation
205187

206188
``` haskell
207-
mod lib
208-
209-
use lib::prelude::(*)
210-
211189
struct Player
212190
level :: Int64
213191
name :: String

.github/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.0
1+
v0.2.1

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rock"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = ["champii <contact@champii>"]
55
edition = "2018"
66

README.md

+4-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rock v0.2.0
1+
# Rock v0.2.1
22

33
[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/Champii/Rock/actions/workflows/rust.yml)
44

@@ -45,10 +45,10 @@ You will need `clang` somewhere in your $PATH
4545

4646
Linux x86_64 only
4747

48-
[Rock v0.2.0](https://github.com/Champii/Rock/releases/download/v0.2.0/rock) (Tested on arch, btw)
48+
[Rock v0.2.1](https://github.com/Champii/Rock/releases/download/v0.2.1/rock) (Tested on arch, btw)
4949

5050
``` sh
51-
wget https://github.com/Champii/Rock/releases/download/v0.2.0/rock
51+
wget https://github.com/Champii/Rock/releases/download/v0.2.1/rock
5252
chmod +x rock
5353
./rock -V
5454
```
@@ -82,15 +82,9 @@ mkdir -P factorial/src && cd factorial
8282

8383
Add some files like this:
8484

85-
- Copy all the stdlib files from [std/src/\*.rk](https://github.com/Champii/Rock/blob/master/std/src) into `factorial/src/`
86-
8785
- Create a `factorial/src/main.rk` file:
8886

8987
```haskell
90-
mod lib
91-
92-
use lib::prelude::(*)
93-
9488
fact a =
9589
if a <= 1
9690
then 1
@@ -121,10 +115,6 @@ Note that you currently must be at the project root to run the compiler. (i.e. i
121115

122116

123117
``` haskell
124-
mod lib
125-
126-
use lib::prelude::(*)
127-
128118
id a = a
129119

130120
main =
@@ -148,10 +138,6 @@ Test
148138
### Custom infix operator
149139

150140
``` haskell
151-
mod lib
152-
153-
use lib::prelude::(*)
154-
155141
infix |> 1
156142
|> x f = f x
157143

@@ -171,10 +157,6 @@ Prints `6`
171157
This `trait ToString` is redondant with the `trait Show` implemented in the lib, and serves as a demonstration only
172158

173159
``` haskell
174-
mod lib
175-
176-
use lib::prelude::(*)
177-
178160
trait ToString a
179161
toString :: a -> String
180162

@@ -204,10 +186,6 @@ Prints
204186
### Struct instance and Show implementation
205187

206188
``` haskell
207-
mod lib
208-
209-
use lib::prelude::(*)
210-
211189
struct Player
212190
level :: Int64
213191
name :: String
@@ -250,7 +228,7 @@ rock --repl
250228
```
251229

252230
``` sh
253-
Rock: v0.2.0
231+
Rock: v0.2.1
254232
----
255233

256234
Type ':?' for help

src/bin/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ fn main() {
141141
.takes_value(false)
142142
.help("Show the InferContext state before solve (DEPRECATED)"),
143143
)
144+
.arg(
145+
Arg::with_name("nostd")
146+
.long("nostd")
147+
.takes_value(false)
148+
.help("Does not include stdlib"),
149+
)
144150
.arg(
145151
Arg::with_name("output-folder")
146152
.short("o")
@@ -163,6 +169,7 @@ fn main() {
163169
repl: matches.is_present("repl"),
164170
no_optimize: matches.is_present("no-optimize"),
165171
build_folder: PathBuf::from(matches.value_of("output-folder").unwrap()),
172+
std: !matches.is_present("nostd"),
166173
..Default::default()
167174
};
168175

src/lib/ast/ast_print.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use std::fmt::Debug;
22

3-
use crate::ast::tree::*;
4-
use crate::ast::visit::*;
5-
use crate::helpers::*;
6-
use crate::ty::*;
73
use paste::paste;
84

5+
use crate::{
6+
ast::{tree::*, visit::*},
7+
helpers::*,
8+
ty::*,
9+
};
10+
911
pub struct AstPrintContext {
1012
indent: usize,
1113
}
@@ -83,7 +85,6 @@ macro_rules! impl_visitor_trait {
8385

8486
impl_visitor_trait!(
8587
Root
86-
// Mod
8788
TopLevel
8889
StructDecl
8990
Use
@@ -92,7 +93,6 @@ impl_visitor_trait!(
9293
Impl
9394
FunctionDecl
9495
Identifier
95-
// ArgumentDecl
9696
Body
9797
Statement
9898
For

src/lib/ast/return_placement.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,20 @@ pub struct ReturnInserter<'a> {
44
pub body: &'a Body,
55
}
66

7+
// TODO: Implement `Visitor` trait for `ReturnInserter`
78
impl<'a> ReturnInserter<'a> {
89
pub fn run(&mut self) -> Body {
910
let mut body = self.body.clone();
1011

1112
self.visit_body(&mut body);
1213

13-
body.clone()
14+
body
1415
}
1516

1617
fn visit_body(&mut self, body: &mut Body) {
17-
// let mut is_assign = None;
18-
1918
if let Some(stmt) = body.stmts.iter_mut().last() {
20-
// if let StatementKind::Assign(ref mut a) = *stmt.kind.clone() {
21-
// is_assign = Some(a.clone());
22-
// }
23-
2419
self.visit_statement(stmt);
2520
}
26-
27-
// if let Some(a) = is_assign {
28-
// body.stmts.push(Statement {
29-
// kind: Box::new(StatementKind::Expression(Box::new(Expression {
30-
// kind: ExpressionKind::Return(Box::new(a.name.as_expression())),
31-
// }))),
32-
// });
33-
// }
3421
}
3522

3623
fn visit_statement(&mut self, stmt: &mut Statement) {

src/lib/ast/tree.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,6 @@ pub enum AssignLeftSide {
379379
Dot(Expression),
380380
}
381381

382-
impl AssignLeftSide {
383-
pub fn as_expression(&self) -> Expression {
384-
match self {
385-
AssignLeftSide::Identifier(i) => i.clone(),
386-
AssignLeftSide::Indice(i) => i.clone(),
387-
AssignLeftSide::Dot(d) => d.clone(),
388-
}
389-
}
390-
}
391-
392382
#[derive(Debug, Clone)]
393383
pub struct Assign {
394384
pub name: AssignLeftSide,
@@ -516,7 +506,8 @@ pub enum Expression {
516506
#[derive(Debug, Clone)]
517507
pub enum UnaryExpr {
518508
PrimaryExpr(PrimaryExpr),
519-
UnaryExpr(Operator, Box<UnaryExpr>),
509+
#[allow(dead_code)]
510+
UnaryExpr(Operator, Box<UnaryExpr>), // Parser for that is not implemented yet
520511
}
521512

522513
impl UnaryExpr {
@@ -603,14 +594,6 @@ impl PrimaryExpr {
603594
}
604595
}
605596

606-
pub fn new_empty(op: Operand) -> PrimaryExpr {
607-
PrimaryExpr {
608-
op,
609-
node_id: u64::MAX,
610-
secondaries: None,
611-
}
612-
}
613-
614597
pub fn new(node_id: NodeId, op: Operand, secondaries: Vec<SecondaryExpr>) -> PrimaryExpr {
615598
PrimaryExpr {
616599
op,
@@ -699,6 +682,8 @@ impl SecondaryExpr {
699682
matches!(self, SecondaryExpr::Dot(_))
700683
}
701684

685+
// might be useful
686+
#[allow(dead_code)]
702687
pub fn is_arguments(&self) -> bool {
703688
matches!(self, SecondaryExpr::Arguments(_))
704689
}

src/lib/ast/visit.rs

-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ generate_visitor_trait!(
4040
StructDecl
4141
Identifier
4242
IdentifierPath
43-
// ArgumentDecl
4443
Body
4544
Statement
4645
For
@@ -138,10 +137,6 @@ pub fn walk_identifier<'a, V: Visitor<'a>>(visitor: &mut V, identifier: &'a Iden
138137
visitor.visit_name(&identifier.name);
139138
}
140139

141-
/* pub fn walk_argument_decl<'a, V: Visitor<'a>>(visitor: &mut V, argument: &'a ArgumentDecl) {
142-
visitor.visit_name(&argument.name);
143-
} */
144-
145140
pub fn walk_body<'a, V: Visitor<'a>>(visitor: &mut V, body: &'a Body) {
146141
walk_list!(visitor, visit_statement, &body.stmts);
147142
}

src/lib/ast_lowering/ast_lowering_context.rs

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl AstLoweringContext {
9494

9595
pub fn lower_struct_decl(&mut self, s: &StructDecl) -> hir::StructDecl {
9696
let hir_t = hir::StructDecl {
97-
// hir_id: self.hir_map.next_hir_id(s.name.node_id),
9897
name: self.lower_identifier(&s.name),
9998
defs: s
10099
.defs
@@ -327,7 +326,6 @@ impl AstLoweringContext {
327326

328327
pub fn lower_struct_ctor(&mut self, s: &StructCtor) -> hir::Expression {
329328
hir::Expression::new_struct_ctor(hir::StructCtor {
330-
// hir_id: self.hir_map.next_hir_id(s.node_id),
331329
name: self.lower_identifier(&s.name),
332330
defs: s
333331
.defs

src/lib/ast_lowering/hir_map.rs

-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ impl HirMap {
5353
pub fn duplicate_hir_mapping(&mut self, hir_id: HirId) -> Option<HirId> {
5454
let node_id = self.get_node_id(&hir_id)?;
5555

56-
/* let mut fake_ident = Identity::new_placeholder();
57-
58-
fake_ident.node_id = node_id; */
59-
6056
let new_id = self.next_hir_id(node_id);
6157

6258
self.add_hir_mapping(new_id.clone(), node_id);

0 commit comments

Comments
 (0)