def execute(source, optimize=True, output=sys.stdout, input=sys.stdin, steps=-1):
    """Compiles and runs program, returning the machine used to execute the
    code.

    Args:
        optimize: Whether to optimize the code after parsing it.
        output: Stream which program can write output to.
        input: Stream which program can read input from.
        steps: An optional maximum number of instructions to execute on the
            virtual machine.  Set to -1 for no limit.

    Returns:
        A Machine instance.
    """
    from crianza import compiler
    code = compiler.compile(parser.parse(source), optimize=optimize)
    machine = Machine(code, output=output, input=input)
    return machine.run(steps)