if (words.length != 0) {
// Se for números
if (words.length == 1 && RegexMatcher.matches(InstructionRegex.RX_NUMBERS, words[0])) {
instruction.setMnemonic(map.get("GeneralCommands"));
instruction.setValue(new Value(words[0], dataType));
// Se for números, define como a posição, a posição atual da linha
// Como posição final é definido a posição inicial + o tamanaho do comando.
// > 123 < Ex: Início 0 Fim 3
instruction.getValue().setValueStartPosition(0);
instruction.getValue().setValueEndPosition(words[0].length());
// System.out.println(line + ": Inicial " + m.getValuePosition().getCaretStartPosition() + " Final:" + m.getValuePosition().getCaretEndPosition());
return instruction;
// Se for linha em branco
} else if (words.length == 1 && (words[0] == null || words[0].equals("\n") || words[0].isEmpty())) {
instruction.setMnemonic(map.get("GeneralCommands"));
// Coloca o valor "0" artificialmente
instruction.setValue(ALU.decimal(0));
instruction.setEmpty(true);
instruction.getValue().setValueStartPosition(0);
instruction.getValue().setValueEndPosition(0);
return instruction;
} else if (words.length == 1) { // Provavelmente este caso serve só para o HLT
// Não define posições, HLT não precisa de substituições.
instruction.setMnemonic(map.get(words[0]));
appendExecutable(instruction);
return instruction;
} // Se nao for nenhum caso acima, entra nesse. (INC AX, LOAD 30, STORE BX)
else if (words.length == 2) {
instruction.setMnemonic(map.get(words[0]));
instruction.setValue(new Value(words[1], dataType));
LineValue lineValue = new LineValue();
String completeInstruction = lineValue.getLineText(position, panel.getCodeTextArea());
int[] valuePosition = getValuePosition(completeInstruction, words[0], words[1]);
instruction.getValue().setValueStartPosition(valuePosition[0]);
instruction.getValue().setValueEndPosition(valuePosition[1]);