diff --git a/LTHCLang_V7.9.0.1.zip b/LTHCLang_V7.9.0.1.zip deleted file mode 100644 index df2383b..0000000 Binary files a/LTHCLang_V7.9.0.1.zip and /dev/null differ diff --git a/LTHCLang_V7.9.0.2.zip b/LTHCLang_V7.9.0.2.zip new file mode 100644 index 0000000..c1f514b Binary files /dev/null and b/LTHCLang_V7.9.0.2.zip differ diff --git a/lthcLangInterpreter.jar b/lthcLangInterpreter.jar index acecac2..d186ebf 100644 Binary files a/lthcLangInterpreter.jar and b/lthcLangInterpreter.jar differ diff --git a/src/lthclang/Decomp.java b/src/lthclang/Decomp.java index 731eb27..f8f9efd 100644 --- a/src/lthclang/Decomp.java +++ b/src/lthclang/Decomp.java @@ -36,9 +36,10 @@ public class Decomp public void executerMethod() { prgmdReader = null; - int index = 0; - while(index < prgm.size()) + int index = -1; + while(index < prgm.size() - 1) { + index++; str = prgm.get(index); splited = str.split(" "); inst = splited[0]; @@ -52,6 +53,7 @@ public void executerMethod() } inst2 = inst2.replace("$n", "\n"); JOptionPane.showMessageDialog(null, inst2); + continue; } //Print with line Instruction if(inst.equals("printl")) @@ -62,6 +64,7 @@ public void executerMethod() inst2 += splited[i] + "\n"; } JOptionPane.showMessageDialog(null, inst2); + continue; } //Create Var @@ -73,12 +76,14 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } } if(isExist == 0) { variable.add(new Var(splited[1].toLowerCase(), Float.parseFloat(splited[2]))); } + continue; } //pvar @@ -94,14 +99,12 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } if(splited[2].equals(var.getName())) { isExist = 1; - } - if(!(splited[3].equals("="))) - { - isExist = 1; + break; } } if(splited.length == 8) @@ -109,18 +112,17 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } if(splited[2].equals(var.getName())) { isExist = 1; + break; } if(splited[3].equals(var.getName())) { isExist = 1; - } - if(!(splited[4].equals("="))) - { - isExist = 1; + break; } } if(splited.length == 10) @@ -128,25 +130,39 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } if(splited[2].equals(var.getName())) { isExist = 1; + break; } if(splited[3].equals(var.getName())) { isExist = 1; + break; } if(splited[4].equals(var.getName())) { isExist = 1; - } - if(!(splited[5].equals("="))) - { - isExist = 1; + break; } } } + if(splited.length == 6 && !(splited[3].equals("="))) + { + isExist = 1; + break; + } + if(splited.length == 8 && !(splited[4].equals("="))) + { + isExist = 1; + break; + } + if(splited.length == 10 && !(splited[5].equals("="))) + { + isExist = 1; + } } else { @@ -173,6 +189,7 @@ public void executerMethod() variable.add(new Var(splited[4].toLowerCase(), Float.parseFloat(splited[9]))); } } + continue; } //PrintVar @@ -183,8 +200,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { JOptionPane.showMessageDialog(null, var.getValue()); + break; } } + continue; } //Add @@ -203,12 +222,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() + varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Sub @@ -227,12 +250,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() - varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Mult @@ -251,12 +278,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() * varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Div @@ -275,12 +306,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() / varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Mod @@ -299,12 +334,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() % varb.getValue()); + break; } } + break; } } + break; } } + continue; } //EDiv @@ -323,12 +362,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue((vara.getValue() - (vara.getValue() % varb.getValue())) / varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Random Int Base @@ -339,8 +382,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(rand.randomInt(Integer.parseInt(splited[2]))); + break; } } + continue; } //Random Int Base With Adjust @@ -351,8 +396,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(rand.randomInt(Integer.parseInt(splited[2]), Integer.parseInt(splited[3]))); + break; } } + continue; } //Random Float @@ -363,8 +410,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(rand.randomFloat()); + break; } } + continue; } //Float Input @@ -375,8 +424,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(floatIn.floatInput()); + break; } } + continue; } //Float Input with custom message if(inst.equals("mfinput")) @@ -391,8 +442,10 @@ public void executerMethod() inst2 += splited[i] + " "; } var.setValue(floatIn.cFloatInput(inst2)); + break; } } + continue; } //Set @@ -403,8 +456,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(Float.parseFloat(splited[2])); + break; } } + continue; } //Str create @@ -416,6 +471,7 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } } if(isExist == 0) @@ -428,6 +484,7 @@ public void executerMethod() inst2 = inst2.replace("$n", "\n"); strVariable.add(new StrVar(splited[1], inst2)); } + continue; } //Strl create if(inst.equals("strl")) @@ -438,6 +495,7 @@ public void executerMethod() if(splited[1].equals(var.getName())) { isExist = 1; + break; } } if(isExist == 0) @@ -449,6 +507,7 @@ public void executerMethod() } strVariable.add(new StrVar(splited[1], inst2)); } + continue; } //PrintStr @@ -459,8 +518,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { JOptionPane.showMessageDialog(null, var.getValue()); + break; } } + continue; } //StrAdd @@ -479,12 +540,16 @@ public void executerMethod() if(splited[3].equals(varb.getName())) { varstock.setValue(vara.getValue() + varb.getValue()); + break; } } + break; } } + break; } } + continue; } //Str Input @@ -495,8 +560,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(strIn.strInput() + " "); + break; } } + continue; } //Str Input with custom message if(inst.equals("msinput")) @@ -511,8 +578,10 @@ public void executerMethod() inst2 += splited[i] + " "; } var.setValue(strIn.cStrInput(inst2)+ " "); + break; } } + continue; } //SetStr @@ -529,8 +598,10 @@ public void executerMethod() } inst2 = inst2.replace("$n", "\n"); var.setValue(inst2); + break; } } + continue; } //SetStrl if(inst.equals("setstrl")) @@ -545,8 +616,10 @@ public void executerMethod() inst2 += splited[i] + "\n"; } var.setValue(inst2); + break; } } + continue; } //Random Str @@ -557,8 +630,10 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(strRand.randStr()); + break; } } + continue; } //Random Str with Size @@ -569,14 +644,17 @@ public void executerMethod() if(splited[1].equals(var.getName())) { var.setValue(strRand.sRandStr(Integer.parseInt(splited[2]))); + break; } } + continue; } //Unconditional Jump if(inst.equals("jmp")) { index = Integer.parseInt(splited[1]) - 2; + continue; } //Conditional Jump [on float] @@ -596,6 +674,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals("<")) { @@ -603,6 +682,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals(">")) { @@ -610,6 +690,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals("!=") || splited[2].equals("=!")) { @@ -617,6 +698,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals("<=") || splited[2].equals("=<")) { @@ -624,6 +706,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals(">=") || splited[2].equals("=>")) { @@ -631,11 +714,14 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } } } + break; } } + continue; } //Conditional Jump [on str] @@ -657,6 +743,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals("!=")) { @@ -666,6 +753,7 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } if(splited[2].equals("=!")) { @@ -675,11 +763,14 @@ public void executerMethod() { index = Integer.parseInt(splited[4]) - 2; } + break; } } } + break; } } + continue; } //Convert float to str @@ -694,10 +785,13 @@ public void executerMethod() if(splited[2].equals(strvar.getName())) { strvar.setValue(var.getValueStr()); + break; } } + break; } } + continue; } //Convert str to float if(inst.equals("strtovar")) @@ -711,10 +805,13 @@ public void executerMethod() if(splited[2].equals(strvar.getName())) { var.setValue(Float.parseFloat(strvar.getValue())); + break; } } + break; } } + continue; } //varlist @@ -726,6 +823,7 @@ public void executerMethod() if(splited[1].equals(list.getName())) { isExist = 1; + break; } } if(isExist == 0) @@ -737,6 +835,7 @@ public void executerMethod() } variableList.add(new ListVar(splited[1], templist)); } + continue; } //varlistset if(inst.equals("varlistset")) @@ -746,8 +845,10 @@ public void executerMethod() if(splited[1].equals(list.getName())) { list.setInList(Integer.parseInt(splited[2]), Float.parseFloat(splited[3])); + break; } } + continue; } //varlistsetall if(inst.equals("varlistsetall")) @@ -762,8 +863,10 @@ public void executerMethod() templist.add(Float.parseFloat(splited[i])); } list.setAllInList(templist); + break; } } + continue; } //varlistadd if(inst.equals("varlistadd")) @@ -773,8 +876,10 @@ public void executerMethod() if(splited[1].equals(list.getName())) { list.addAtEndOfList(Float.parseFloat(splited[2])); + break; } } + continue; } //varlistaddv if(inst.equals("varlistaddv")) @@ -788,10 +893,13 @@ public void executerMethod() if(splited[2].equals(var.getName())) { list.addAtEndOfList(var.getValue()); + break; } } + break; } } + continue; } //varlistremoveat if(inst.equals("varlistremoveat")) @@ -801,8 +909,10 @@ public void executerMethod() if(splited[1].equals(list.getName())) { list.removeAt(Integer.parseInt(splited[2])); + break; } } + continue; } //pset @@ -1031,6 +1141,7 @@ public void executerMethod() } } } + continue; } //varlistsize @@ -1045,10 +1156,13 @@ public void executerMethod() if(splited[2].equals(var.getName())) { var.setValue(list.getList().size()); + break; } } + break; } } + continue; } //printvarlist if(inst.equals("printvarlist")) @@ -1063,11 +1177,11 @@ public void executerMethod() out += list.getList().get(i).toString() + "\n"; } JOptionPane.showMessageDialog(null, out); + break; } } + continue; } - - index++; } } -} +} \ No newline at end of file diff --git a/src/lthclang/Reader.java b/src/lthclang/Reader.java index 3a7f243..0708010 100644 --- a/src/lthclang/Reader.java +++ b/src/lthclang/Reader.java @@ -31,6 +31,7 @@ public void prgmReader() String str; while((str = br.readLine()) != null) { + if (str.equalsIgnoreCase("\n")) continue; prgm.add(str); } br.close(); @@ -51,4 +52,4 @@ public void prgmReader() } public List getPrgm() {return prgm;} -} +} \ No newline at end of file diff --git a/src/lthclang/basicinst/numinst/RandomInstSet.java b/src/lthclang/basicinst/numinst/RandomInstSet.java index 3b2ead0..401d8a1 100644 --- a/src/lthclang/basicinst/numinst/RandomInstSet.java +++ b/src/lthclang/basicinst/numinst/RandomInstSet.java @@ -25,4 +25,4 @@ public float randomFloat() Random rand = new Random(); return rand.nextFloat(); } -} +} \ No newline at end of file diff --git a/src/lthclang/basicinst/strinst/RandomStrInstSet.java b/src/lthclang/basicinst/strinst/RandomStrInstSet.java index d74e988..155e636 100644 --- a/src/lthclang/basicinst/strinst/RandomStrInstSet.java +++ b/src/lthclang/basicinst/strinst/RandomStrInstSet.java @@ -4,265 +4,143 @@ public class RandomStrInstSet { + private int random; + private Random rand = new Random(); + public RandomStrInstSet() { // TODO Auto-generated constructor stub } public String randStr() { - String str =""; - Random rand = new Random(); - int random = 1 + rand.nextInt(62); - if(random == 1) - { - str = "a"; - } - if(random == 2) - { - str = "b"; - } - if(random == 3) - { - str = "c"; - } - if(random == 4) - { - str = "d"; - } - if(random == 5) - { - str = "e"; - } - if(random == 6) - { - str = "f"; - } - if(random == 7) - { - str = "g"; - } - if(random == 8) - { - str = "h"; - } - if(random == 9) - { - str = "i"; - } - if(random == 10) - { - str = "j"; - } - if(random == 11) - { - str = "k"; - } - if(random == 12) - { - str = "l"; - } - if(random == 13) - { - str = "m"; - } - if(random == 14) - { - str = "n"; - } - if(random == 15) - { - str = "o"; - } - if(random == 16) - { - str = "p"; - } - if(random == 17) - { - str = "q"; - } - if(random == 18) - { - str = "r"; - } - if(random == 19) - { - str = "s"; - } - if(random == 20) - { - str = "t"; - } - if(random == 21) - { - str = "u"; - } - if(random == 22) - { - str = "v"; - } - if(random == 23) - { - str = "w"; - } - if(random == 24) - { - str = "x"; - } - if(random == 25) - { - str = "y"; - } - if(random == 26) - { - str = "z"; - } - if(random == 27) - { - str = "A"; - } - if(random == 28) - { - str = "B"; - } - if(random == 29) - { - str = "C"; - } - if(random == 30) - { - str = "D"; - } - if(random == 31) - { - str = "E"; - } - if(random == 32) - { - str = "F"; - } - if(random == 33) - { - str = "G"; - } - if(random == 34) - { - str = "H"; - } - if(random == 35) - { - str = "I"; - } - if(random == 36) - { - str = "J"; - } - if(random == 37) - { - str = "K"; - } - if(random == 38) - { - str = "L"; - } - if(random == 39) - { - str = "M"; - } - if(random == 40) - { - str = "N"; - } - if(random == 41) - { - str = "O"; - } - if(random == 42) - { - str = "P"; - } - if(random == 43) - { - str = "Q"; - } - if(random == 44) - { - str = "R"; - } - if(random == 45) - { - str = "S"; - } - if(random == 46) - { - str = "T"; - } - if(random == 47) - { - str = "U"; - } - if(random == 48) - { - str = "V"; - } - if(random == 49) - { - str = "W"; - } - if(random == 50) - { - str = "X"; - } - if(random == 51) - { - str = "Y"; - } - if(random == 52) - { - str = "Z"; - } - if(random == 53) - { - str = "0"; - } - if(random == 54) - { - str = "1"; - } - if(random == 55) - { - str = "2"; - } - if(random == 56) - { - str = "3"; - } - if(random == 57) - { - str = "4"; - } - if(random == 58) - { - str = "5"; - } - if(random == 59) - { - str = "6"; - } - if(random == 60) - { - str = "7"; - } - if(random == 61) - { - str = "8"; - } - if(random == 62) - { - str = "9"; - } + random = 1 + rand.nextInt(62); - return str; + switch (random) { + case 1: + return "a"; + case 2: + return "b"; + case 3: + return "c"; + case 4: + return "d"; + case 5: + return "e"; + case 6: + return "f"; + case 7: + return "g"; + case 8: + return "h"; + case 9: + return "i"; + case 10: + return "j"; + case 11: + return "k"; + case 12: + return "l"; + case 13: + return "m"; + case 14: + return "n"; + case 15: + return "o"; + case 16: + return "p"; + case 17: + return "q"; + case 18: + return "r"; + case 19: + return "s"; + case 20: + return "t"; + case 21: + return "u"; + case 22: + return "v"; + case 23: + return "w"; + case 24: + return "x"; + case 25: + return "y"; + case 26: + return "z"; + case 27: + return "A"; + case 28: + return "B"; + case 29: + return "C"; + case 30: + return "D"; + case 31: + return "E"; + case 32: + return "F"; + case 33: + return "G"; + case 34: + return "H"; + case 35: + return "I"; + case 36: + return "J"; + case 37: + return "K"; + case 38: + return "L"; + case 39: + return "M"; + case 40: + return "N"; + case 41: + return "O"; + case 42: + return "P"; + case 43: + return "Q"; + case 44: + return "R"; + case 45: + return "S"; + case 46: + return "T"; + case 47: + return "U"; + case 48: + return "V"; + case 49: + return "W"; + case 50: + return "X"; + case 51: + return "Y"; + case 52: + return "Z"; + case 53: + return "0"; + case 54: + return "1"; + case 55: + return "2"; + case 56: + return "3"; + case 57: + return "4"; + case 58: + return "5"; + case 59: + return "6"; + case 60: + return "7"; + case 61: + return "8"; + default: + return "9"; + } } public String sRandStr(int size) @@ -274,4 +152,4 @@ public String sRandStr(int size) } return str; } -} +} \ No newline at end of file diff --git a/src/lthclang/basicinst/strinst/StrAddInstSet.java b/src/lthclang/basicinst/strinst/StrAddInstSet.java deleted file mode 100644 index a5fd712..0000000 --- a/src/lthclang/basicinst/strinst/StrAddInstSet.java +++ /dev/null @@ -1,13 +0,0 @@ -package lthclang.basicinst.strinst; - -public class StrAddInstSet -{ - public StrAddInstSet() { - // TODO Auto-generated constructor stub - } - - public String addStr(String str1, String str2) - { - return str1 + str2; - } -} diff --git a/src/lthclang/basicinst/strinst/StrInputInstSet.java b/src/lthclang/basicinst/strinst/StrInputInstSet.java index b0f0fd1..242b676 100644 --- a/src/lthclang/basicinst/strinst/StrInputInstSet.java +++ b/src/lthclang/basicinst/strinst/StrInputInstSet.java @@ -17,4 +17,4 @@ public String cStrInput(String msg) { return JOptionPane.showInputDialog(msg); } -} +} \ No newline at end of file diff --git a/src/lthclang/var/number/ListVar.java b/src/lthclang/var/number/ListVar.java index d0c17f1..0c3d0c9 100644 --- a/src/lthclang/var/number/ListVar.java +++ b/src/lthclang/var/number/ListVar.java @@ -50,4 +50,4 @@ public String getName() { return this.name; } -} +} \ No newline at end of file diff --git a/src/lthclang/var/number/Var.java b/src/lthclang/var/number/Var.java index ba7dd37..4714940 100644 --- a/src/lthclang/var/number/Var.java +++ b/src/lthclang/var/number/Var.java @@ -26,4 +26,4 @@ public void setValue(float value) { public String getName() { return name; } -} +} \ No newline at end of file diff --git a/src/lthclang/var/str/StrVar.java b/src/lthclang/var/str/StrVar.java index 9b77fb1..c61cd12 100644 --- a/src/lthclang/var/str/StrVar.java +++ b/src/lthclang/var/str/StrVar.java @@ -21,4 +21,4 @@ public void setValue(String value) { public String getName() { return this.name; } -} +} \ No newline at end of file