re: Why does my Dint ISE stop working after declaring a new variable of any type? VIEW POST

FULL DISCUSSION
 

When you ask for help you need to give the specific areas of code or issues you believe you're having trouble with.

You have to help people to help you; none of this code is documented or commented up. I'm also not certain that everything you've left out is irrelevant but that's because I basically have to trace half your program to figure out the problem. It may just be me but I'm actually not even sure what the expected result is.

You are far more likely to find solutions to your problems if you run through the code, explain important parts of it and show what you've tried in order to solve the problem. That will help people to better understand what you're asking and often in the process of doing this you'll just figure out the problem yourself.

 

I would try, but It's that sometimes I have had prombles with entire files, would limiting it just to the Lexer class, and only including the 'required' variables help?

 

I can't get any more specific than this.... Sorry, can you please accept this? I don't know how to simplify it any more than removing the few commands from the list of commands...

class Lexer {
    public static Parser execute = new Parser();
    public static void startParse() {
        Scanner input = new Scanner(System.in);
        List<String> pStrings = new ArrayList<String>();
        List<String> pStringVals = new ArrayList<String>();
        List<String> pInts = new ArrayList<String>();
        List<Integer> pIntVals = new ArrayList<Integer>();
        List<String> pDoubles = new ArrayList<String>();
        List<Double> pDoubleVals = new ArrayList<Double>();
        List<String> pFuncs = new ArrayList<String>();
        List<String> pFuncVals = new ArrayList<String>();
        List<String> pBool = new ArrayList<String>();
        List<Boolean> pBoolVals = new ArrayList<Boolean>();
        int lineIs = 1;
        while(true) {
            String in = input.nextLine();
            String lineArgs = in;
            String tok = "";
            String Background_tok = "";
            String numberString = "";
            String doubleString = "";
            String string = "";
            String function = "";
            String gateType = "None";
            String command = null;
            List<String> stringS = new ArrayList<String>();
            List<Integer> numberS = new ArrayList<Integer>();
            List<Double> doubleS = new ArrayList<Double>();
            Integer numberInt;
            int state = 0;
            int errors = 0;
            boolean conditions = false;
            double doubleDouble;
            for(int i = 0; i < in.length();) {
                tok += in.charAt(i);
                Background_tok += in.charAt(i);
                if(state == 1) {
                    string += in.charAt(i);
                    if(!(tok.equals("\""))) {
                        tok = "";
                        Background_tok = "";
                    }
                } else if(state == 2) {
                    if(tok.equals("1") || tok.equals("2") || tok.equals("3") || tok.equals("4") || tok.equals("5") || tok.equals("6") || tok.equals("7") || tok.equals("8") || tok.equals("9") || tok.equals("0")) {
                        numberString += tok;
                    }
                    if(Background_tok.equals("<Random>")) {
                        Background_tok = "";
                        Random pRandomNumber = new Random();
                        Integer pRandNum = pRandomNumber.nextInt(100);
                        pRandNum += 1;
                        numberString = pRandNum.toString();
                    }
                    if(!(tok.equals("|"))) {
                        tok = "";
                    }
                } else if(state == 3) {
                    if(tok.equals("1") || tok.equals("2") || tok.equals("3") || tok.equals("4") || tok.equals("5") || tok.equals("6") || tok.equals("7") || tok.equals("8") || tok.equals("9") || tok.equals("0") || tok.equals(".")) {
                        doubleString += tok;
                    }
                    if(Background_tok.equals("<pi>")) {
                        tok = "";
                        Background_tok = "";
                        doubleString = "3.14159";
                    }
                    if(!(tok.equals("/"))) {
                        tok = "";
                    }
                }
                if(tok.equals(" ")) {
                    tok = "";
                    if(Background_tok.equals(" ")) {
                        Background_tok = " ";
                    }
                } else if(tok.equals("\"") && (state == 0 || state == 1)) {
                    if(state == 0) {
                        state = 1;
                    } else {
                        state = 0;
                        string = string.substring(0, string.length() - 1);
                        stringS.add(string);
                        string = "";
                    }
                    tok = "";
                    Background_tok = "";
                } else if(tok.equals("|") && (state == 0 || state == 2)) {
                    if(state == 0) {
                        state = 2;
                    } else {
                        state = 0;
                        try{
                            numberInt = Integer.parseInt(numberString);
                            numberS.add(numberInt);
                        } catch(Exception e) {
                            System.out.println("IntNotAcceptedError: Expected type <Int>, but got type <String> = <Blank> = <Null>\nError at: line "+lineIs);
                            System.out.println(lineArgs);
                            System.out.println("Error at: line "+lineIs);
                            System.out.println(errors+" errors");
                            errors++;
                        }
                    }
                    tok = "";
                    Background_tok = "";
                } else if(tok.equals("/") && (state == 0 || state == 3)) {
                    if(state == 0) {
                        state = 3;
                    } else {
                        state = 0;
                        try{
                            doubleDouble = Double.parseDouble(doubleString);
                            doubleS.add(doubleDouble);
                        } catch(Exception e) {
                            System.out.println("DoubleNotAcceptedError: Expected type <Int>, but got type <String> = <Blank> = <Null>\nError at: line "+lineIs);
                            System.out.println(lineArgs);
                            System.out.println("Error at: line "+lineIs);
                            System.out.println(errors+" errors");
                            errors++;
                        }
                    }
                    tok = "";
                    Background_tok = "";
                } else if(tok.equals("String") && state == 0) {
                    try{
                        pStrings.add(stringS.get(0));
                        pStringVals.add(stringS.get(1));
                    } catch(Exception e) {
                        System.out.println("VariableArguementError: Not all arguements were properly met in the declaration, Error at line "+lineIs);
                        System.out.println(lineArgs);
                        System.out.println("Error at: line "+lineIs);
                        System.out.println(errors+" errors");
                        errors++;
                    }
                    tok = "";
                    Background_tok = "";
                } else if(tok.equals("int")) {
                    try {
                        pInts.add(stringS.get(0));
                        pIntVals.add(numberS.get(0));
                    } catch(Exception e) {
                        System.out.println("VariableArguementError: Not all arguements were properly met in the declaration, Error at line "+lineIs);
                        System.out.println(lineArgs);
                        System.out.println("Error at: line "+lineIs);
                        System.out.println(errors+" errors");
                        errors++;
                    }
                } else if(tok.equals("double")) {
                    try {
                        pDoubles.add(stringS.get(0));
                        pDoubleVals.add(doubleS.get(0));
                    } catch(Exception e) {
                        System.out.println("VariableArguementError: Not all arguements were properly met in the declaration, Error at line "+lineIs);
                        System.out.println(lineArgs);
                        System.out.println("Error at: line "+lineIs);
                        System.out.println(errors+" errors");
                        errors++;
                    }
                } else if(tok.equals("@Variables")) {
                    for(int iter = 0; iter < pStrings.size();) {
                        System.out.println(pStrings.get(iter)+" : "+pStringVals);
                    }
                    for(int iter = 0; iter < pInts.size();) {
                        System.out.println(pInts.get(iter)+" : "+pIntVals);
                    }
                    for(int iter = 0; iter < pDoubles.size();) {
                        System.out.println(pDoubles.get(iter)+" : "+pDoubleVals);
                    }
                } else {
                    try {
                        boolean objectFound = false;
                        String placeholderForVar = "";
                        for(int iter = 0; iter < pStrings.size();) {
                            placeholderForVar = pStrings.get(i);
                            if(placeholderForVar.equals(tok)) {
                                objectFound = true;
                                stringS.add(pStringVals.get(i));
                                break;
                            }
                            i++;
                        }
                        for(int iter = 0; iter < pInts.size();) {
                            placeholderForVar = pInts.get(i);
                            if(placeholderForVar.equals(tok)) {
                                objectFound = true;
                                numberS.add(pIntVals.get(i));
                                break;
                            }
                            i++;
                        }
                        for(int iter = 0; iter < pDoubles.size();) {
                            placeholderForVar = pDoubles.get(i);
                            if(placeholderForVar.equals(tok)) {
                                objectFound = true;
                                doubleS.add(pDoubleVals.get(i));
                                break;
                            }
                            i++;
                        }
                        if(objectFound == false) {
                            //
                        }
                    } catch(Exception e) {
                        //
                    }
                }
                i++;
            }
            execute.parse(command, stringS, numberS, doubleS, lineIs, lineArgs);
            lineIs++;
        }
    }
}
code of conduct - report abuse