brain/codegen/
statements.rs1use parser::{Statement};
2use instructions::Instructions;
3use memory::MemoryLayout;
4
5use super::errors::Error;
6use super::output::output_expr;
7use super::input::read_input;
8use super::declarations::declare;
9use super::while_loop::while_loop;
10
11pub fn expand(
13 instructions: &mut Instructions,
14 mem: &mut MemoryLayout,
15 stmt: Statement
16) -> Result<(), Error> {
17 match stmt {
18 Statement::Comment(_) => Ok(()),
19 Statement::Output(exprs) => {
20 for expr in exprs {
21 output_expr(instructions, mem, expr)?;
22 }
23 Ok(())
24 },
25 Statement::Input {name, slice} => read_input(instructions, mem, name, slice),
26 Statement::Declaration {name, slice, expr} => declare(instructions, mem, name, slice, expr),
27 Statement::WhileLoop {condition, body} => while_loop(instructions, mem, condition, body),
28 }
29}