Fix Cleaner unzip one, fix logic
This commit is contained in:
parent
800ad9a4e9
commit
be289b8d7f
4 changed files with 16 additions and 17 deletions
|
@ -36,15 +36,18 @@ public class CleanerPool{
|
|||
String zip = cleaner.getConstant(key);
|
||||
String modified = modifier.apply(zip, cleaner.getPattern());
|
||||
if(modified == null) continue;
|
||||
map.put(key, cleaner.open+zip+cleaner.close);
|
||||
tmp = matcher.group(1)+cleaner.open+zip+cleaner.close+matcher.group(3);
|
||||
map.put(key, cleaner.open+modified+cleaner.close);
|
||||
tmp = matcher.group(1)+cleaner.open+modified+cleaner.close+matcher.group(3);
|
||||
edited = true;
|
||||
}
|
||||
}
|
||||
}while(edited);
|
||||
|
||||
|
||||
for(Entry<String, String> unzip : map.entrySet()) value = value.replaceAll("\\"+unzip.getKey()+"(?<e>([^\\d]|$))", unzip.getValue()+"${e}");
|
||||
|
||||
String base = value;
|
||||
for(Entry<String, String> unzip : map.entrySet()){
|
||||
Pattern pattern = Pattern.compile("\\"+unzip.getKey()+"(?<e>([^\\d]|$))");
|
||||
if(pattern.matcher(base).find()) value = pattern.matcher(value).replaceAll(unzip.getValue()+"${e}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -34,13 +34,17 @@ public class Function extends OperationContainer{
|
|||
parameters(matcher.group(3)+";", cleaner);
|
||||
this.exceptions = matcher.group(4).trim();
|
||||
|
||||
System.out.println("body IS {"+matcher.group(5));
|
||||
CleanerPool generic = new CleanerPool(new Cleaner("GENERIC_FUNCTION", '{', '}'));
|
||||
String zip = generic.clean("{"+matcher.group(5));
|
||||
System.out.println("clean it "+zip);
|
||||
String body = generic.unzipOne(zip, (s,p) -> s);
|
||||
String unzip = body.substring(1, body.indexOf('}'));
|
||||
System.out.println("----------Before------------");
|
||||
show(0);
|
||||
System.out.println("----------------------------");
|
||||
|
||||
System.out.println("BODY LIKE "+body);
|
||||
parse(unzip, cleaner, generic);
|
||||
System.out.println("----------After------------");
|
||||
show(0);
|
||||
|
|
|
@ -19,6 +19,7 @@ public abstract class OperationContainer extends JavaElement{
|
|||
}
|
||||
|
||||
public void parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
System.out.println("RECEIVE CONAINER "+content);
|
||||
content = local.unzip(content, (s,p) -> s);
|
||||
System.out.println("CONTAINER "+content);
|
||||
while(!(content.replaceAll("\\s+", "").isEmpty())) content = internalParse(content, global, local);
|
||||
|
|
|
@ -32,10 +32,11 @@ public class OperationFactory{
|
|||
this.patterns.put(Pattern.compile("^\\s*while\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), WhileOperation.class);
|
||||
this.patterns.put(Pattern.compile("^\\s*else\\s*.*$"), ElseOperation.class);
|
||||
|
||||
this.patterns.put(Pattern.compile("^\\s*([^;=]+;).*$"), MethodCallOperation.class);
|
||||
this.patterns.put(Pattern.compile("^\\s*[^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+;.*$"), MethodCallOperation.class);
|
||||
|
||||
this.patterns.put(Pattern.compile("^\\s*[^\\s]+\\s+[^\\s]+\\s*=\\s*[^;]+;.*$"), Variable.class);
|
||||
this.patterns.put(Pattern.compile("^\\s*[^\\s]+\\s*=\\s*[^;]+;.*$"), AssigmentOperation.class);
|
||||
this.patterns.put(Pattern.compile("^\\s*[^;]+;.*$"), Variable.class);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -87,25 +88,15 @@ public class OperationFactory{
|
|||
private static Pattern UNZIP_EQUALS_RIGHT = Pattern.compile("=(?<e>[^=\\s])");
|
||||
|
||||
private String generiqueTypes(String content, CleanerPool cleaner){
|
||||
System.out.println("base on "+content);
|
||||
String unzip = cleaner.unzip(content, (value, pattern) -> {
|
||||
System.out.println("unzip pattern "+pattern);
|
||||
if(pattern.equals("^GENERIC_FUNCTION")) return null;
|
||||
if(pattern.equals("^GENERIC_PARENTHESIS")) return null;
|
||||
System.out.println("let pass "+pattern);
|
||||
if(pattern.equals("^GENERIC_FUNCTION") || pattern.equals("^GENERIC_PARENTHESIS")) return null;
|
||||
return value.replaceAll("\\s+", "");
|
||||
});
|
||||
System.out.println("generiqueTypes on "+unzip);
|
||||
unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}");
|
||||
System.out.println("g => "+unzip);
|
||||
unzip = UNZIP_MAJ.matcher(unzip).replaceAll("> ${e}");
|
||||
System.out.println("g => "+unzip);
|
||||
unzip = UNZIP_ARRAY.matcher(unzip).replaceAll("] ${e}");
|
||||
System.out.println("g => "+unzip);
|
||||
unzip = UNZIP_EQUALS_LEFT.matcher(unzip).replaceAll("${e} =");
|
||||
System.out.println("g => "+unzip);
|
||||
unzip = UNZIP_EQUALS_RIGHT.matcher(unzip).replaceAll("= ${e}");
|
||||
System.out.println("g => "+unzip);
|
||||
return unzip;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue