// Path: src/main/java/com/amanvishnani/sim8085/domain/IAddress.java
// public interface IAddress {
//     String hexValue();
//     Integer intValue();
//     IData getLSB();
//     IData getMSB();
//     IData getData();
//     void setData(IData data);
//     static IAddress ZERO = Address.from(0);
//     static IAddress FFFF = Address.from("FFFF");
// }
// 
// Path: src/main/java/com/amanvishnani/sim8085/domain/IData.java
// public interface IData {
//     IData ZERO = Data.from("00");
//     String hexValue();
//     Integer intValue();
//     IOperationResult add(IData data);
//     IOperationResult add(IData data, Integer carry);
//     IOperationResult minus(IData data);
//     IRegister toRegister();
//     public IData getLSB();
// }
// 
// Path: src/main/java/com/amanvishnani/sim8085/domain/IOpcode.java
// public interface IOpcode {
//     String getInstruction();
//     IData getOpcodeData();
//     Integer getOpcodeLength();
// }


import com.amanvishnani.sim8085.domain.IAddress;
import com.amanvishnani.sim8085.domain.IData;
import com.amanvishnani.sim8085.domain.IOpcode;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
    public Pattern[] patterns = new Pattern[246];
    public final String data = "[0-9A-F]{2}(H)?";
    public final String label = "[A-Za-z]{3}[A-Za-z]*";
    public final String addr = "[0-9A-F]{4}(H)?";
    public final String space = "( )*";
    public final String space1 = "( )+";
    public Matcher m;

    public Parser() {
        this.initializePatt();
    }

    public List<String> getLineInstructions(String code) {
        String[] code_token = code.split("\\n");
        List<String> temp= new ArrayList<>();

        for (int j = 0; j < code_token.length; j++) {
            code_token[j] = trimSpaces(code_token[j]);
            if (0 != code_token[j].length()) {
                temp.add(code_token[j]);
            }
        }
        return temp;
    }

    private String trimSpaces(String x) {
        x = x.trim().replaceAll(" +", " ");
        return x;
    }

// Path: src/main/java/com/amanvishnani/sim8085/domain/IAddress.java
// public interface IAddress {
//     String hexValue();
//     Integer intValue();
//     IData getLSB();
//     IData getMSB();
//     IData getData();
//     void setData(IData data);
//     static IAddress ZERO = Address.from(0);
//     static IAddress FFFF = Address.from("FFFF");
// }
// 
// Path: src/main/java/com/amanvishnani/sim8085/domain/IData.java
// public interface IData {
//     IData ZERO = Data.from("00");
//     String hexValue();
//     Integer intValue();
//     IOperationResult add(IData data);
//     IOperationResult add(IData data, Integer carry);
//     IOperationResult minus(IData data);
//     IRegister toRegister();
//     public IData getLSB();
// }
// 
// Path: src/main/java/com/amanvishnani/sim8085/domain/IOpcode.java
// public interface IOpcode {
//     String getInstruction();
//     IData getOpcodeData();
//     Integer getOpcodeLength();
// }


// Path: src/main/java/com/amanvishnani/sim8085/domain/Impl/Parser.java
import com.amanvishnani.sim8085.domain.IAddress;
import com.amanvishnani.sim8085.domain.IData;
import com.amanvishnani.sim8085.domain.IOpcode;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

    public Pattern[] patterns = new Pattern[246];
    public final String data = "[0-9A-F]{2}(H)?";
    public final String label = "[A-Za-z]{3}[A-Za-z]*";
    public final String addr = "[0-9A-F]{4}(H)?";
    public final String space = "( )*";
    public final String space1 = "( )+";
    public Matcher m;

    public Parser() {
        this.initializePatt();
    }

    public List<String> getLineInstructions(String code) {
        String[] code_token = code.split("\\n");
        List<String> temp= new ArrayList<>();

        for (int j = 0; j < code_token.length; j++) {
            code_token[j] = trimSpaces(code_token[j]);
            if (0 != code_token[j].length()) {
                temp.add(code_token[j]);
            }
        }
        return temp;
    }

    private String trimSpaces(String x) {
        x = x.trim().replaceAll(" +", " ");
        return x;
    }

    public IOpcode getOpcode(String lineInstruction) {