factorio-ir 0.1.1

Intermediate representation for factorio-rs Rust-to-Lua transpilation
Documentation
use crate::{expression::Expression, function::Function, structure::Struct, r#type::Type};

#[derive(Debug, Clone, PartialEq)]
pub enum Statement {
    FunctionDecl(Function),
    StructDecl(Struct),
    VariableDecl {
        name: String,
        ty: Type,
        source_type: Option<String>,
        value: Expression,
    },
    Assignment {
        target: Expression,
        value: Expression,
    },
    Conditional {
        condition: Expression,
        then_block: Vec<Self>,
        else_block: Vec<Self>,
    },
    Return(Option<Expression>),
    Expr(Expression),
    /// `for _, VAR in pairs(ITER) do BODY end` in Lua.
    ForIn {
        var: String,
        iter: Expression,
        body: Vec<Self>,
    },
    /// `goto __continue_N` in Lua (the label `::__continue_N::` is emitted by the enclosing `ForIn`).
    Continue,
}