Examples of LineValue


Examples of br.com.gmartins.simbler.helpers.LineValue

    }

    @Override
    protected List<Instruction> doInBackground() throws Exception {
        SyntacticAnalyzer analyzer = new SyntacticAnalyzer(panel);
        LineValue lineValueGetter = new LineValue();
        setProgressVisible(true, this.panel.getCodeTextArea().getLineCount());
        for (int position = 0; position < this.getLineCount(); position++) {
            String lineValue = lineValueGetter.getLineText(position, panel.getCodeTextArea());
            StringBuilder formattedLine = new StringBuilder();
            // Verifica palavra por palavra da linha digitada e monta
            // o StringBuilder devidamente formatado
            if (checkWordByWord(lineValue, formattedLine, position) == false) {
                if (silentMode == false) {
View Full Code Here

Examples of br.com.gmartins.simbler.helpers.LineValue

            valueToAdd = 1;
        }
        // Guarda a Posição atual do Cursor de Texto
        int CaretPos = cmdArea.getCaretPosition();
        // Pega a Linha atual do JTextArea
        int LinePos = new LineValue().getCurrentLineNumber(cmdArea, cmdArea.getCaretPosition());
        // Faz um for varrendo todos comandos procurando por "JMP"
        for (int i = 0; i < cmdLinha.length; i++) {
            // Quebra a Linha em Comandos
            // Por exemplo - cmdLinha[i] = "JMP 5"
            // cmdWord[0] = "JMP"
            // cmdWord[1] = "5"


            cmdLinha[i] = cmdLinha[i].trim(); // Remove os espaços da String
            String[] cmdWord = cmdLinha[i].split(InstructionRegex.RX_SPACES_BETWEEN); // Divide a String em palavras (Separada todos os espaços)

            Map<String, MnemonicDetails> map = MnemonicsMap.getInstance().getMnemonicsMap();

            // Verifica se na lista de Mnemonicos existe algum comando com o nome capturado em cmdWord[0]
            if (map.containsKey(cmdWord[0])) {
                MnemonicDetails m = map.get(cmdWord[0]);

                // Se sim, atribui ele em "m" e faz um for em todas as expressões disponíveis desse comando
                for (InstructionRegex regex : m.getRegexList()) {

                    // Se a expressão for vinculável (definida em MnemicsRegex) e a expressão casar com o valor da minha (cmdLinha[i])
                    // Quer dizer que esse comando contém vínculos e deve ser alterado
                    if (regex.isLinkable() && RegexMatcher.matches(regex.getRegex(true) + InstructionRegex.RX_COMMENTS, cmdLinha[i])) {
                        //  Preciso de alguma forma identificar os comentarios e devolve-los corretamente apos a insercao do enter.
                        //        Procurar também uma forma de fazer o backspace.
                        String guardaComentarios = "";
                        if (cmdLinha[i].contains(";")) { // Se existirem comentários
                            guardaComentarios = RegexMatcher.getMatch(regex.getRegex(true) + InstructionRegex.RX_COMMENTS, cmdLinha[i]);
                            guardaComentarios = guardaComentarios.replaceAll(regex.getRegex(true), "");
                            // Remove de toda a linha os comentários
                            cmdLinha[i] = cmdLinha[i].replace(guardaComentarios, "");
                            cmdWord = cmdLinha[i].split(InstructionRegex.RX_SPACES_BETWEEN);
                        }
                        // Se a palavra depois do comando tiver @, é necessário trata-lo de devolve-lo corretamente ao valor alterado.
                        if (cmdWord[1].substring(0, 1).equals("@")) {
                            // Se a posicão da linha for menor ou igual a do vínculo, então é necessário atualiza-lo.
                            // Se a linha for anterior, é necessário atualizar pois todas as linhas posteriores serão afetadas com o enter.
                            // Se for igual, ele ainda faz parte da alteração do enter e deve ser atualizado.
                            if (LinePos <= Integer.parseInt(cmdWord[1].substring(1))) {
                                int value = Integer.parseInt(cmdWord[1].substring(1)) + valueToAdd;
                                // Junta o JMP + o novo valor
                                cmdLinha[i] = m.getName() + " @" + value;
                            }
                        } // Se não, apenas acrescenta 1 ao seu valor
                        else {
                            if (LinePos <= Integer.parseInt(cmdWord[1])) {
                                int value = Integer.parseInt(cmdWord[1]) + valueToAdd;
                                // Junta o JMP + o novo valor
                                cmdLinha[i] = m.getName() + " " + value;
                            }
                        }

                        cmdLinha[i] += guardaComentarios;
                    }
                }
            }

        }
        // Limpa a area de texto e reescreve
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < cmdLinha.length; i++) {
            str.append(cmdLinha[i]);
            // Evita que seja inserida uma linha após o último comando.
            if (cmdLinha.length - 1 != i) {
                str.append("\n");
            }
        }

        cmdArea.setText(str.toString());


        try {
            CaretPos = cmdArea.getLineStartOffset(LinePos);
        } catch (BadLocationException ex) {
            Logger.getLogger(LinkUpdater.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (operationMode == ENTER_MODE) {
            cmdArea.insert("\n", CaretPos);
        } else if (operationMode == BACKSPACE_MODE) {
            LineValue lineValue = new LineValue();
            lineValue.getLineText(LinePos, cmdArea, false);
            cmdArea.replaceRange("", lineValue.getCaretPositionLineStart() - 1, lineValue.getCaretPositionLineEnd());
        }

        cmdArea.setCaretPosition(CaretPos);

    }
View Full Code Here

Examples of br.com.gmartins.simbler.helpers.LineValue

                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]);

                if (lineValue.getLineText(position, panel.getCodeTextArea(), false).contains("@")) {
                    instruction.setHasLinks(true);
                }

                appendExecutable(instruction);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.