mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
Compare commits
No commits in common. "e6b31b39b0b056638d3b73dd6966668a36c89435" and "7ac147de325587c80b4a7ef0460f9541239d218d" have entirely different histories.
e6b31b39b0
...
7ac147de32
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -114,14 +114,6 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "holymer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chumsky",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -191,6 +183,14 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "renxi"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chumsky",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stacker"
|
||||
version = "0.1.15"
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
[package]
|
||||
name = "holymer"
|
||||
name = "renxi"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
chumsky = "0.9.0"
|
||||
structopt = "0.3.26"
|
||||
|
||||
[[bin]]
|
||||
name = "hlmc"
|
||||
path = "src/main.rs"
|
|
@ -1 +1,2 @@
|
|||
ko_fi: azur1s
|
||||
github: azur1s
|
5
a.hlm
5
a.hlm
|
@ -1 +1,4 @@
|
|||
print("Hello\n");
|
||||
let x: num = 1,
|
||||
y: num = 2,
|
||||
in
|
||||
println(if x + y == 3 then 69 else 0);
|
|
@ -1,8 +0,0 @@
|
|||
func fact (n : num) num =
|
||||
if n == 0 then
|
||||
1
|
||||
else
|
||||
n * fact(n - 1)
|
||||
;
|
||||
|
||||
println(fact(5));
|
|
@ -14,7 +14,7 @@ pub enum JSExpr {
|
|||
Op(&'static str, Box<Self>, Option<Box<Self>>),
|
||||
|
||||
Call(Box<Self>, Vec<Self>),
|
||||
Method(Box<Self>, String),
|
||||
Method(Box<Self>, String, Vec<Self>),
|
||||
Lambda {
|
||||
args: Vec<String>,
|
||||
body: Vec<Self>,
|
||||
|
@ -75,7 +75,16 @@ impl Display for JSExpr {
|
|||
}
|
||||
write!(f, ")")
|
||||
},
|
||||
JSExpr::Method(c, m) => write!(f, "{}.{}", c, m),
|
||||
JSExpr::Method(c, m, args) => {
|
||||
write!(f, "{}.{}(", c, m)?;
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", arg)?;
|
||||
}
|
||||
write!(f, ")")
|
||||
},
|
||||
JSExpr::Lambda { args, body } => {
|
||||
write!(f, "((")?;
|
||||
for (i, name) in args.iter().enumerate() {
|
||||
|
|
|
@ -154,21 +154,13 @@ pub fn translate_js_expr(expr: Expr) -> JSExpr {
|
|||
match *f {
|
||||
Expr::Sym(ref s) => {
|
||||
match s.as_str() {
|
||||
"println" => JSExpr::Call(
|
||||
Box::new(JSExpr::Method(
|
||||
"println" => {
|
||||
JSExpr::Method(
|
||||
Box::new(JSExpr::Sym("console".to_string())),
|
||||
"log".to_string(),
|
||||
)),
|
||||
args.into_iter().map(translate_js_expr).collect()),
|
||||
"print" => JSExpr::Call(
|
||||
Box::new(JSExpr::Method(
|
||||
Box::new(JSExpr::Method(
|
||||
Box::new(JSExpr::Sym("process".to_string())),
|
||||
"stdout".to_string(),
|
||||
)),
|
||||
"write".to_string(),
|
||||
)),
|
||||
args.into_iter().map(translate_js_expr).collect()),
|
||||
args.into_iter().map(translate_js_expr).collect(),
|
||||
)
|
||||
},
|
||||
_ => JSExpr::Call(
|
||||
Box::new(translate_js_expr(*f)),
|
||||
args.into_iter().map(translate_js_expr).collect(),
|
||||
|
|
Loading…
Reference in a new issue