OOO-Processor-Simulator / src / main.py
main.py
Raw
import json
import os
import sys
#from jsonschema import validate
from processor import Processor

# Define the JSON schema for validating the input file
instruction_schema = {
    "type": "array",
    "items": {"type": "string"}
}

def read_input_file(file_path):
    with open(file_path, 'r') as f:
        data = json.load(f)


    return data


def main():
    if len(sys.argv) != 3:
        print("Usage: python main.py <input_file> <output_file>")
        exit(1)

    input_file = sys.argv[1]
    output_file = sys.argv[2]

    if os.path.exists(output_file):
        os.remove(output_file)

    # Read and parse the JSON input file
    instructions = read_input_file(input_file)

    # Initialize the processor
    processor = Processor(instructions)

    # Run the simulation
    processor.run_simulation(output_file)


if __name__ == "__main__":
    main()