DEV: Let bindings work.

This commit is contained in:
Jeremy Wall 2019-08-02 18:57:52 -05:00
parent c792d758d7
commit 52a66bae8b
2 changed files with 14 additions and 1 deletions

View File

@ -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![

View File

@ -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")
}