fn generic_init<'a>(
    statement: &'a Statement,
    target: &str,
    float: bool,
    simple_factory: &dyn Fn(usize, bool) -> Simple,
) -> Instruction {
    let conds = conditions(statement);
    if let Noun::Identifier(id) = statement.subject {
        if target == "POWER" { // Hacky way to allow for FLOATing POWER
            Instruction::Simple(simple_factory(id, float))
        }
        else if let (None, None) = conds {
            if !statement.action_sign {
                Instruction::Simple(simple_factory(id, float))
            }
            else {
                // NOT [type] is a no-op
                Instruction::NoOp
            }
        }
        else {
            throw_error(
                ErrorType::InstructionValidationError, 
                format!("IS {} cannot be defined with conditions", target),
                None
            );
            Instruction::NoOp

        }
    }
    else {
        throw_error(
            ErrorType::InstructionValidationError, 
            format!("Cannot initialize {:?} as {}", statement.subject, target),
            None
        );
        Instruction::NoOp
    }
}
/// Returns an INIT instruction with default parameters.
/// 
/// Does not allow for conditionals. NOT returns a no-op.
Returns an INIT instruction with default parameters.
Does not allow for conditionals. NOT returns a no-op.
Returns an INIT instruction with default parameters . Does not allow for conditionals . NOT returns a no - op .
fn generic_init<'a>(
    statement: &'a Statement,
    target: &str,
    float: bool,
    simple_factory: &dyn Fn(usize, bool) -> Simple,
) -> Instruction {
    let conds = conditions(statement);
    if let Noun::Identifier(id) = statement.subject {
        if target == "POWER" { // Hacky way to allow for FLOATing POWER
            Instruction::Simple(simple_factory(id, float))
        }
        else if let (None, None) = conds {
            if !statement.action_sign {
                Instruction::Simple(simple_factory(id, float))
            }
            else {
                // NOT [type] is a no-op
                Instruction::NoOp
            }
        }
        else {
            throw_error(
                ErrorType::InstructionValidationError, 
                format!("IS {} cannot be defined with conditions", target),
                None
            );
            Instruction::NoOp
        }
    }
    else {
        throw_error(
            ErrorType::InstructionValidationError, 
            format!("Cannot initialize {:?} as {}", statement.subject, target),
            None
        );
        Instruction::NoOp
    }
}
fn generic_init < ' a > ( statement : & ' a Statement , target : & str , float : bool , simple_factory : & dyn Fn ( usize , bool ) -> Simple , ) -> Instruction { let conds = conditions ( statement ) ; if let Noun :: Identifier ( id ) = statement . subject { if target == " " { // Hacky way to allow for FLOATing POWER Instruction :: Simple ( simple_factory ( id , float ) ) } else if let ( None , None ) = conds { if ! statement . action_sign { Instruction :: Simple ( simple_factory ( id , float ) ) } else { // NOT [type] is a no-op Instruction :: NoOp } } else { throw_error ( ErrorType :: InstructionValidationError , format ! ( " " target ) , None ) ; Instruction :: NoOp } } else { throw_error ( ErrorType :: InstructionValidationError , format ! ( " " statement subject target ) , None ) ; Instruction :: NoOp } }
Returns an INIT instruction with default parameters.
Returns an INIT instruction with default parameters .
statement
&'a Statement
target
&str
float
bool
simple_factory
&dyn Fn(usize, bool) -> Simple
statement
&'a Statement
target
&str
float
bool
simple_factory
&dyn Fn(usize, bool) -> Simple