mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
Compare commits
2 commits
a8e6dad433
...
24dbfc23ff
Author | SHA1 | Date | |
---|---|---|---|
Natapat Samutpong | 24dbfc23ff | ||
Natapat Samutpong | 40a7d1d3c3 |
11
README.md
11
README.md
|
@ -19,6 +19,17 @@ end;
|
||||||
|
|
||||||
Note: Everything in this project can be changed at anytime! (I'm still finding out what work best for lots of thing) if you have an idea, feel free to create an issues about it, or even create a PR! (I'd be very happy)
|
Note: Everything in this project can be changed at anytime! (I'm still finding out what work best for lots of thing) if you have an idea, feel free to create an issues about it, or even create a PR! (I'd be very happy)
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
Found a bug? Found a better way to do something? Make a pull request or tell me in the issues tab! Anything contributions helps :D
|
||||||
|
|
||||||
|
Wanna see how it works under the hood? see the [How it works](https://github.com/azur1s/hazure#how-it-works) tab, you should probably understand it a bit more.
|
||||||
|
|
||||||
|
Steps to build:
|
||||||
|
1) Clone this repo `https://github.com/azur1s/hazure.git`
|
||||||
|
2) Run `sudo make build-lib` to build the library (for the transpiled output)
|
||||||
|
3) Build executable `cargo build`
|
||||||
|
4) Try running some examples! `path/to/executable compile path/to/file.hz`
|
||||||
|
|
||||||
# How it works
|
# How it works
|
||||||
```
|
```
|
||||||
Source (.hz)
|
Source (.hz)
|
||||||
|
|
|
@ -116,12 +116,13 @@ pub fn expr_to_ir(expr: &Expr) -> (Option<IRKind>, Option<LoweringError>) {
|
||||||
_ => return (None, Some(LoweringError { span: name.1.clone(), message: "Expected identifier".to_string(), note: None }))
|
_ => return (None, Some(LoweringError { span: name.1.clone(), message: "Expected identifier".to_string(), note: None }))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove all `Hole`(s) from the args
|
// Get the index where the `Hole` is at
|
||||||
let index = args.0.iter().position(|arg| match arg.0 {
|
let index = args.0.iter().position(|arg| match arg.0 {
|
||||||
Expr::Hole(..) => true,
|
Expr::Hole(..) => true,
|
||||||
_ => false
|
_ => false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If there is no `Hole` in the args then return early
|
||||||
if let None = index {
|
if let None = index {
|
||||||
return (None, Some(LoweringError {
|
return (None, Some(LoweringError {
|
||||||
span: rhs.1.clone(),
|
span: rhs.1.clone(),
|
||||||
|
@ -130,6 +131,7 @@ pub fn expr_to_ir(expr: &Expr) -> (Option<IRKind>, Option<LoweringError>) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the `Hole` from the args
|
||||||
let mut new_args = args.0.clone();
|
let mut new_args = args.0.clone();
|
||||||
new_args.remove(index.unwrap());
|
new_args.remove(index.unwrap());
|
||||||
|
|
||||||
|
@ -152,6 +154,7 @@ pub fn expr_to_ir(expr: &Expr) -> (Option<IRKind>, Option<LoweringError>) {
|
||||||
let mut largs = Vec::new();
|
let mut largs = Vec::new();
|
||||||
for arg in &args.0 {
|
for arg in &args.0 {
|
||||||
match arg.0 {
|
match arg.0 {
|
||||||
|
// If the arg is a `Hole` then replace it with the lowered IR
|
||||||
Expr::Hole(..) => {
|
Expr::Hole(..) => {
|
||||||
largs.push(lhs_ir.0.clone().unwrap());
|
largs.push(lhs_ir.0.clone().unwrap());
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,8 +2,4 @@ fun main: int = do
|
||||||
-- Normal way of hello world
|
-- Normal way of hello world
|
||||||
@write("Hello, World!\n");
|
@write("Hello, World!\n");
|
||||||
return 69;
|
return 69;
|
||||||
|
|
||||||
-- Hello world piped to @write() function
|
|
||||||
"Hello, World!\n"
|
|
||||||
|> @write();
|
|
||||||
end;
|
end;
|
Loading…
Reference in a new issue