mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
DEV: Let bindings work.
This commit is contained in:
parent
c792d758d7
commit
52a66bae8b
@ -606,6 +606,14 @@ fn simple_binary_expr() {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_let_statements() {
|
||||
assert_parse_cases![
|
||||
"let foo = 1; foo;" => P(Int(1)),
|
||||
"let foo = 1 + 1; foo;" => P(Int(2)),
|
||||
];
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dot_expressions() {
|
||||
let mut ops = vec![
|
||||
|
@ -27,7 +27,12 @@ impl AST {
|
||||
Statement::Assert(_, _) => {
|
||||
unimplemented!("Assert statements are not implmented yet")
|
||||
}
|
||||
Statement::Let(_) => unimplemented!("Let statements are not implmented yet"),
|
||||
Statement::Let(def) => {
|
||||
let binding = def.name.fragment;
|
||||
ops.push(Op::Sym(binding));
|
||||
Self::translate_expr(def.value, &mut ops);
|
||||
ops.push(Op::Bind);
|
||||
}
|
||||
Statement::Output(_, _, _) => {
|
||||
unimplemented!("Out statements are not implmented yet")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user