🦉 hey fukurou your skills are required for a job

fukurou

the supreme coder
Staff member
Administrator
Java:
public class Java2Python {
    String funnelMode = "default";
    ArrayList<String> attributes = new EasyCollections().getStrArrayList();
    
}

 

fukurou

the supreme coder
Staff member
Administrator
Java:
public class Java2Python {
    private String funnelMode = "default";
    private ArrayList<String> attributes = new EasyCollections().getStrArrayList();
    private RegexUtil regexUtil = new RegexUtil();

    public HashSet<String> breakToLines(String code) {
        String[] strgs = code.split(";");
        String sentence = "";
        HashSet<String> uniqueLines = new HashSet<>();
        for (String str1 : strgs) {
            uniqueLines.add(str1);
        }
        return uniqueLines;
    }
}
 

owly

闇の伝説
battle programer
funnel modes :
attributes
getters
setters
static methods
methods
functions
c'tor

 

fukurou

the supreme coder
Staff member
Administrator
Code:
def indirect(i):
    switcher = {
        0: zero,
        1: one,
        2: lambda: 'two'
    }
    func = switcher.get(i, lambda: 'Invalid')
    return func()


def zero():
    print("test ok")
    return 'zero'


def one():
    return 'one'


print(indirect(0))

switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}
 

fukurou

the supreme coder
Staff member
Administrator
Java:
package pkg2;

import java.util.ArrayList;
import java.util.HashSet;

import LG_Core.RegexUtil;

public class Java2Python {
    // TODO
    /**
     * attributes, static, methods, functions, c'tors
     */
    private String funnelMode = "default";
    private ArrayList<String> attributes = new EasyCollections().getStrArrayList();
    private RegexUtil regexUtil = new RegexUtil();
    private String switchCase = "";
    private Boolean firstCase = false;
    // private String carryOnCode = ""; // for switch codes
    // private String switchFunctions = ""; // for switch codes
    // private Boolean funnelSwitch = false;
    // private int switchIndex = -1;
    // private int switchCaseIndex = 1;

    public HashSet<String> breakToLines(String code) {
        String[] strgs = code.split(";");
        String sentence = "";
        HashSet<String> uniqueLines = new HashSet<>();
        for (String str1 : strgs) {
            uniqueLines.add(str1);
        }
        return uniqueLines;
    }

    public String forLoop(String str1) {
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", str1);
        if (loopDeclaration.isEmpty()) {
            return str1;
        }
        String init = regexUtil.numberRegex(loopDeclaration);
        String index = regexUtil.between("int ", init, loopDeclaration).replace(" =", "");
        String condition = regexUtil.between("; ", ";", loopDeclaration);
        String forsBool = regexUtil.between("; ", ";", loopDeclaration);
        String jump = regexUtil.between(forsBool + "; ", "\\)", loopDeclaration);
        String result = index + " = " + init;
        result = result + "\n" + "while (" + condition + "):";
        result = result + "\n    " + jump;
        result = str1.replace(loopDeclaration, result);
        System.out.println(result);
        return result;
    }

    // public String switchTranlate(String str1) {
    // String result = str1;
    // if (result.contains("switch")) {
    // switchIndex++;
    // String v1 = regexUtil.between("switch\\(", "\\)", str1);
    // result = "switch_" + this.switchIndex + "(" + v1 + ")";
    // String temp = "def indirect(i):\n" + " switcher = {";
    // temp = temp.replace("(i", "(" + v1);
    // carryOnCode = carryOnCode +temp;
    // System.out.println(temp);
    // }
    // else if(result.contains("case ")) {
    // this.funnelSwitch = true;
    // result = result.replace("case ", "")+"sfunc"+switchIndex+"_"+switchCaseIndex;
    //
    // return "";
    // }
    // return result;
    // }
    public String switchTranlate(String str1) {
        String result = str1;
        if (result.contains("switch")) {
            this.switchCase = regexUtil.between("switch\\(", "\\)", str1);
            this.firstCase = true;
            result = "# this was a switch case";
    }
        if (str1.contains("case ") && this.firstCase) {
            result = "if(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            this.firstCase = false;
            return result;
        }
        if (str1.contains("case ") && !this.firstCase) {
            result = "elif(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            return result;
        }
        if (str1.contains("default")) {
            result = "else:";
        }
        return result;
    }
    public String methodToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        return result;
    }
}

 

fukurou

the supreme coder
Staff member
Administrator
Java:
    public String clsTranslate(String str1) {
        String result = "";
        if (str1.contains("extends")) {
            String clsName = regexUtil.between("class", "extends", str1).trim();
            result = "class " + clsName;
            String parentCls = regexUtil.between("extends", " \\{", str1).trim();
            result = result + "(" + parentCls + ")";
        }
        else {
            String clsName = regexUtil.between("class", " \\{", str1).trim();
            result = "class " + clsName;
        }
        return result + ":";
    }
 

fukurou

the supreme coder
Staff member
Administrator
Java:
public class J2Py {
    private String funnelMode = "default";
    private ArrayList<String> attributes = new EasyCollections().getStrArrayList();
    private RegexUtil regexUtil = new RegexUtil();
    private Boolean firstCase = false;

    public HashSet<String> breakToLines(String code) {
        String[] strgs = code.split(";");
        String sentence = "";
        HashSet<String> uniqueLines = new HashSet<>();
        for (String str1 : strgs) {
            uniqueLines.add(str1);
        }
        return uniqueLines;
    }

    // stage 1
    public String clsNAttributes(String str1) {
        if (str1.contains("class")) {
            return clsTranslate(str1);
        }
        String result = str1.replace("public", "");
        result = result.replace("private", "");
        result = result.replace("protected", "");
        result = result.trim();
        if (Character.isUpperCase(result.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
            attributes.add(result.substring(0, result.indexOf(" ")));
        }
        return result;
    }

    // stage x function
    public String functionToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // for loop ?
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", line);
        if (!loopDeclaration.isEmpty()) {
            result = forLoop(loopDeclaration);
        }
        // switch ?
        result = switchTranlate(result);
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        // filter out
        result = result.replace("break", "");
        return result;
    }

    private String forLoop(String loopDeclaration) {
        String init = regexUtil.numberRegex(loopDeclaration);
        String index = regexUtil.between("int ", init, loopDeclaration).replace(" =", "");
        String condition = regexUtil.between("; ", ";", loopDeclaration);
        String forsBool = regexUtil.between("; ", ";", loopDeclaration);
        String jump = regexUtil.between(forsBool + "; ", "\\)", loopDeclaration);
        String result = index + " = " + init;
        result = result + "\n" + "while (" + condition + "):";
        result = result + "\n    " + jump;
        return result;
    }

    public String switchTranlate(String str1) {
        String result = str1;
        if (result.contains("switch")) {
            return "# this was a switch case";
        }
        if (str1.contains("case ") && this.firstCase) {
            result = "if(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            this.firstCase = false;
            return result;
        }
        if (str1.contains("case ") && !this.firstCase) {
            result = "elif(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            return result;
        }
        if (str1.contains("default")) {
            result = "else:";
        }
        return result;
    }

    private String clsTranslate(String str1) {
        String result = "";
        if (str1.contains("extends")) {
            String clsName = regexUtil.between("class", "extends", str1).trim();
            result = "class " + clsName;
            String parentCls = regexUtil.between("extends", " \\{", str1).trim();
            result = result + "(" + parentCls + ")";
        } else {
            String clsName = regexUtil.between("class", " \\{", str1).trim();
            result = "class " + clsName;
        }
        return result + ":";
    }
}
 

owly

闇の伝説
battle programer
Code:
public class J2Py {
    private String funnelMode = "default";
    private ArrayList<String> attributes = new EasyCollections().getStrArrayList();
    private RegexUtil regexUtil = new RegexUtil();
    private Boolean firstCase = false;

    public HashSet<String> breakToLines(String code) {
        String[] strgs = code.split(";");
        String sentence = "";
        HashSet<String> uniqueLines = new HashSet<>();
        for (String str1 : strgs) {
            uniqueLines.add(str1);
        }
        return uniqueLines;
    }

    // stage 1
    public String clsNAttributes(String str1) {
        if (str1.contains("class")) {
            return clsTranslate(str1);
        }
        String result = str1.replace("public", "");
        result = result.replace("private", "");
        result = result.replace("protected", "");
        result = result.trim();
        if (Character.isUpperCase(result.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
            attributes.add(result.substring(0, result.indexOf(" ")));
        }
        return result;
    }

    // stage x function
    public String functionToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // for loop ?
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", line);
        if (!loopDeclaration.isEmpty()) {
            result = forLoop(loopDeclaration);
        }
        // switch ?
        result = switchTranlate(result);
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        // filter out
        result = result.replace("break", "");
        return result;
    }

    // stage 3 methode
    public String methodToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.replace("(", "(self,");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // for loop ?
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", line);
        if (!loopDeclaration.isEmpty()) {
            result = forLoop(loopDeclaration);
        }
        // switch ?
        result = switchTranlate(result);
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // method addaptor
        result = result.replace("this.", "self.");
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        // filter out
        result = result.replace("break", "");
        return result;
    }

    private String forLoop(String loopDeclaration) {
        String init = regexUtil.numberRegex(loopDeclaration);
        String index = regexUtil.between("int ", init, loopDeclaration).replace(" =", "");
        String condition = regexUtil.between("; ", ";", loopDeclaration);
        String forsBool = regexUtil.between("; ", ";", loopDeclaration);
        String jump = regexUtil.between(forsBool + "; ", "\\)", loopDeclaration);
        String result = index + " = " + init;
        result = result + "\n" + "while (" + condition + "):";
        result = result + "\n    " + jump;
        return result;
    }

    public String switchTranlate(String str1) {
        String result = str1;
        if (result.contains("switch")) {
            return "# this was a switch case";
        }
        if (str1.contains("case ") && this.firstCase) {
            result = "if(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            this.firstCase = false;
            return result;
        }
        if (str1.contains("case ") && !this.firstCase) {
            result = "elif(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            return result;
        }
        if (str1.contains("default")) {
            result = "else:";
        }
        return result;
    }

    private String clsTranslate(String str1) {
        String result = "";
        if (str1.contains("extends")) {
            String clsName = regexUtil.between("class", "extends", str1).trim();
            result = "class " + clsName;
            String parentCls = regexUtil.between("extends", " \\{", str1).trim();
            result = result + "(" + parentCls + ")";
        } else {
            String clsName = regexUtil.between("class", " \\{", str1).trim();
            result = "class " + clsName;
        }
        return result + ":";
    }
}
 

fukurou

the supreme coder
Staff member
Administrator
Java:
public class Main2 {
    static ChobitV2 chi1 = new ChobitV2(new Personality2());

    public static void main(String[] args) {
        cbVoid();
        cbVoid();
        cbOut("say hello", "", "");
        cbOut("what is the time at lithuania", "", "");
        PasswordGenerator passwordGenerator = new PasswordGenerator.PasswordGeneratorBuilder().useDigits(true)
                .useLower(true).useUpper(true).build();
        String password = passwordGenerator.generate(16);
        System.out.println(password);
        System.out.println(TimeZoneUtil.timeAt("los angeles"));
        // python
        JavaToPython javaToPython = new JavaToPython();
        System.out.println(javaToPython.methodToPython("public void input(String ear, String skin, String eye) {"));
        javaToPython.forLoop("for (int i = 0; i < 5; i++)");
        Java2Python j2py = new Java2Python();
        System.out.println(j2py.switchTranlate("switch(expression) {"));
        System.out.println(j2py.switchTranlate("case x:"));
        System.out.println(j2py.switchTranlate("case y:"));
        System.out.println(j2py.switchTranlate("default:"));
        System.out.println(j2py.clsTranslate("public class DiSkillV2 {"));
        TimeZoneUtil tz = new TimeZoneUtil();
        System.out.println(tz.timeAt(9));
        String scam = "studiosupport@clips4sale.com";
        System.out.println(scam.equals("studiosupport@clips4sale.com"));
        J2Py j2PyV1 = new J2Py();
        System.out.println(j2PyV1.functionToPython("for (int i = 0; i < 5; i++)"));
        System.out.println(j2PyV1.functionToPython("switch(expression) {"));
        System.out.println(j2PyV1.methodToPython("this.kokoro = kokoro;"));
        String f1 = "public class DiSkillV2 extends AbsCmdReq {\r\n" + "    protected Kokoro kokoro;\r\n"
                + "    protected DISkillUtils diSkillUtils = new DISkillUtils();\r\n"
                + "    protected Algorithm outAlg = null;";
        j2PyV1.translateAttributesNClass(f1);
        f1 = "    public final void output(Neuron noiron) {\r\n" + "        if (outAlg != null) {\r\n"
                + "            noiron.algParts.add(outAlg);\r\n" + "            this.outAlg = null;\r\n"
                + "        }\r\n"
                + "    }";
        // j2PyV1.translateFunction(f1);
        j2PyV1.translateMethod(f1);
    }
    public static void cbOut(String a, String b, String c) {
        System.out.println(chi1.doIt(a, b, c));
    }
    public static void cbVoid() {
        System.out.println(chi1.doIt("", "", ""));
    }

    public static Boolean bigTosmall(int... a) {
        for (int i = 0; i < a.length - 1; i++) {
            if (!(a[i] > a[i + 1])) {
                return false;
            }
        }
        return true;
    }

    public static int miner(int... a) {
        int minimum = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] < minimum) {
                minimum = a[i];
            }
        }
        return minimum;
    }

    public static int maxer(int... a) {
        int maximum = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] > maximum) {
                maximum = a[i];
            }
        }
        return maximum;
    }

    public static void brownReaserch(int r, int g, int b) {
        // r>g>=b
        System.out.println("r-g= " + (r - g) + " " + " g-b=" + (g - b));
    }
}

done
 

fukurou

the supreme coder
Staff member
Administrator
Java:
public class J2Py {
    private String funnelMode = "default";
    // private ArrayList<String> attributes = new
    // EasyCollections().getStrArrayList();
    private RegexUtil regexUtil = new RegexUtil();
    private Boolean firstCase = false;
    private String INDENT = "    ";

    public ArrayList<String> breakToLines(String code) {
        String[] strgs = code.split(";");
        String sentence = "";
        ArrayList<String> lines = new EasyCollections().getStrArrayList();
        for (String str1 : strgs) {
            lines.add(str1);
        }
        return lines;
    }

    public ArrayList<String> breakToLinesV2(String code) {
        code = code.replaceFirst("\\{", ";");
        String[] strgs = code.split(";");
        String sentence = "";
        ArrayList<String> lines = new EasyCollections().getStrArrayList();
        for (String str1 : strgs) {
            lines.add(str1);
        }
        return lines;
    }
    public void translateAttributesNClass(String str1) {
        ArrayList<String> lines = breakToLinesV2(str1);
        String result = "";
        for (int counter = 0; counter < lines.size(); counter++) {
            String temp = clsNAttributes(lines.get(counter));
            if (!temp.contains("class")) {
                temp = INDENT + temp;
            }
            System.out.println(temp);
        }
    }

    public void translateFunction(String str1) {
        ArrayList<String> lines = breakToLinesV2(str1);
        String result = "";
        for (int counter = 0; counter < lines.size(); counter++) {
            String temp = functionToPython(lines.get(counter));
            System.out.println(temp);
            }
    }

    public void translateMethod(String str1) {
        ArrayList<String> lines = breakToLinesV2(str1);
        String result = "";
        for (int counter = 0; counter < lines.size(); counter++) {
            String temp = methodToPython(lines.get(counter));
            System.out.println(temp);
        }
    }
    // stage 1
    public String clsNAttributes(String str1) {
        if (str1.contains("class")) {
            return clsTranslate(str1);
        }
        String result = str1.replace("public", "");
        result = result.replace("private", "");
        result = result.replace("protected", "");
        result = result.trim();
        if (Character.isUpperCase(result.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
            // attributes.add(result.substring(0, result.indexOf(" ")));
        }
        return result;
    }

    // stage x function
    public String functionToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // for loop ?
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", line);
        if (!loopDeclaration.isEmpty()) {
            result = forLoop(loopDeclaration);
        }
        // switch ?
        result = switchTranlate(result);
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        // filter out
        result = result.replace("break", "");
        return result;
    }

    // stage 3 methode
    public String methodToPython(String line) {
        // meth declaration
        Boolean isMethodDeclaration = line.contains("public") || line.contains("private") || line.contains("protected");
        String result = line;
        if (isMethodDeclaration) {
            result = line.replace("public", "");
            result = result.replace("private", "");
            result = result.replace("protected", "");
            result = result.replace("(", "(self,");
            result = result.trim();
            result = result.substring(result.indexOf(" "));
            result = result.replace(" {", ":");
            result = "def" + result;
        }
        // for loop ?
        String loopDeclaration = regexUtil.regexChecker("for\\s*\\([^;]*?;[^;]*?;[^)]*?\\)", line);
        if (!loopDeclaration.isEmpty()) {
            result = forLoop(loopDeclaration);
        }
        // switch ?
        result = switchTranlate(result);
        // common codes
        result = result.replace("System.out.println", "print");
        // var declaration
        String var2Check = result.trim();
        if (Character.isUpperCase(var2Check.charAt(0))) {
            result = result.substring(result.indexOf(" ") + 1);
            result = result.replace("new ", "");
        }
        // method addaptor
        result = result.replace("this.", "self.");
        // if
        if (result.contains("if")) {
            result = result.replace(") {", ") :");
            // Boolean gates
            result = result.replace("&&", "AND");
            result = result.replace("||", "OR");
            result = result.replace("!", "NOT");
        }
        // end brackets elimination
        result = result.replace("{", "");
        result = result.replace("}", "");
        // filter out
        result = result.replace("break", "");
        return result;
    }

    private String forLoop(String loopDeclaration) {
        String init = regexUtil.numberRegex(loopDeclaration);
        String index = regexUtil.between("int ", init, loopDeclaration).replace(" =", "");
        String condition = regexUtil.between("; ", ";", loopDeclaration);
        String forsBool = regexUtil.between("; ", ";", loopDeclaration);
        String jump = regexUtil.between(forsBool + "; ", "\\)", loopDeclaration);
        String result = index + " = " + init;
        result = result + "\n" + "while (" + condition + "):";
        result = result + "\n    " + jump;
        return result;
    }

    public String switchTranlate(String str1) {
        String result = str1;
        if (result.contains("switch")) {
            return "# this was a switch case";
        }
        if (str1.contains("case ") && this.firstCase) {
            result = "if(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            this.firstCase = false;
            return result;
        }
        if (str1.contains("case ") && !this.firstCase) {
            result = "elif(" + this.firstCase + "==" + str1.replace("case ", "").replace(":", "") + "):";
            return result;
        }
        if (str1.contains("default")) {
            result = "else:";
        }
        return result;
    }

    private String clsTranslate(String str1) {
        String result = "";
        if (str1.contains("extends")) {
            String clsName = regexUtil.between("class", "extends", str1).trim();
            result = "class " + clsName;
            String parentCls = regexUtil.between("extends", " \\{", str1).trim();
            result = result + "(" + parentCls + ")";
        } else {
            String clsName = regexUtil.between("class", " \\{", str1).trim();
            result = "class " + clsName;
        }
        return result + ":";
    }
}
 
Top