Compare commits
No commits in common. "f4ff094554fa35e9b826754306e9357061dda2fa" and "800ad9a4e91f75d5382286aecd2ae4b9180cc6c2" have entirely different histories.
f4ff094554
...
800ad9a4e9
13 changed files with 101 additions and 155 deletions
|
@ -19,7 +19,7 @@ public class Class extends JavaElement{
|
|||
|
||||
public Class(){}
|
||||
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class Class extends JavaElement{
|
|||
int equals = indexOf(content,"=");
|
||||
if((quotes < braces && quotes < equals) || (equals < braces)){
|
||||
Variable variable = new Variable();
|
||||
int index = variable.parse(content, global, local);
|
||||
int index = variable.parse(content, cleaner);
|
||||
content = content.substring(index);
|
||||
boolean quote = content.startsWith(",");
|
||||
if(quote){
|
||||
|
@ -49,7 +49,7 @@ public class Class extends JavaElement{
|
|||
multiple.addVariable(variable.getName(), variable.getValue());
|
||||
while(quote){
|
||||
variable = new Variable(variable.getModifier(), variable.getType());
|
||||
index = variable.parse(content, global, local);
|
||||
index = variable.parse(content, cleaner);
|
||||
content = content.substring(index);
|
||||
quote = content.startsWith(",");
|
||||
if(quote) content = content.substring(1);
|
||||
|
@ -66,7 +66,7 @@ public class Class extends JavaElement{
|
|||
}else{
|
||||
// System.out.println("Function "+content);
|
||||
Function func = new Function();
|
||||
int index = func.parse(content, global, local);
|
||||
int index = func.parse(content, cleaner);
|
||||
this.childs.add(func);
|
||||
content = content.substring(index);
|
||||
// System.out.println("End "+content);
|
||||
|
|
|
@ -15,34 +15,7 @@ public class CleanerPool{
|
|||
private List<Cleaner> cleaners;
|
||||
|
||||
public CleanerPool(Cleaner... cleaners){
|
||||
this.cleaners = new ArrayList<>(Arrays.asList(cleaners));
|
||||
}
|
||||
|
||||
public CleanerPool group(CleanerPool... pools){
|
||||
CleanerPool pool = new CleanerPool();
|
||||
pool.cleaners.addAll(cleaners);
|
||||
for(CleanerPool other : pools){
|
||||
for(Cleaner cleaner : other.cleaners){
|
||||
boolean contains = false;
|
||||
for(Cleaner include : pool.cleaners){
|
||||
if(include.getPattern().equals(cleaner.getPattern())){
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(contains) continue;
|
||||
pool.cleaners.add(cleaner);
|
||||
}
|
||||
}
|
||||
return pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
String s = "CleanerPool[\n";
|
||||
for(Cleaner cleaner : cleaners) s+=cleaner.pattern+"['"+cleaner.open+"' -> '"+cleaner.close+"']\n";
|
||||
s+="\n]";
|
||||
return s;
|
||||
this.cleaners = Arrays.asList(cleaners);
|
||||
}
|
||||
|
||||
public String clean(String value){
|
||||
|
@ -63,18 +36,15 @@ public class CleanerPool{
|
|||
String zip = cleaner.getConstant(key);
|
||||
String modified = modifier.apply(zip, cleaner.getPattern());
|
||||
if(modified == null) continue;
|
||||
map.put(key, cleaner.open+modified+cleaner.close);
|
||||
tmp = matcher.group(1)+cleaner.open+modified+cleaner.close+matcher.group(3);
|
||||
map.put(key, cleaner.open+zip+cleaner.close);
|
||||
tmp = matcher.group(1)+cleaner.open+zip+cleaner.close+matcher.group(3);
|
||||
edited = true;
|
||||
}
|
||||
}
|
||||
}while(edited);
|
||||
|
||||
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}");
|
||||
}
|
||||
|
||||
for(Entry<String, String> unzip : map.entrySet()) value = value.replaceAll("\\"+unzip.getKey()+"(?<e>([^\\d]|$))", unzip.getValue()+"${e}");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -26,30 +26,27 @@ public class Function extends OperationContainer{
|
|||
this.parameters = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
attribute(matcher.group(2));
|
||||
parameters(matcher.group(3)+";", global, local);
|
||||
parameters(matcher.group(3)+";", cleaner);
|
||||
this.exceptions = matcher.group(4).trim();
|
||||
|
||||
local = new CleanerPool(
|
||||
new Cleaner("GENERIC_FUNCTION", '{', '}'),
|
||||
new Cleaner("GENERIC_PARENTHESIS", '(', ')'));
|
||||
String zip = local.clean("{"+matcher.group(5));
|
||||
String body = local.unzipOne(zip, (s,p) -> s);
|
||||
CleanerPool generic = new CleanerPool(new Cleaner("GENERIC_FUNCTION", '{', '}'));
|
||||
String zip = generic.clean("{"+matcher.group(5));
|
||||
String body = generic.unzipOne(zip, (s,p) -> s);
|
||||
String unzip = body.substring(1, body.indexOf('}'));
|
||||
|
||||
System.out.println("----------before----------");
|
||||
System.out.println("----------Before------------");
|
||||
show(0);
|
||||
|
||||
super.parse(local.clean(unzip), global, local);
|
||||
|
||||
System.out.println("----------After----------");
|
||||
System.out.println("----------------------------");
|
||||
parse(unzip, cleaner, generic);
|
||||
System.out.println("----------After------------");
|
||||
show(0);
|
||||
System.out.println("---------------------------");
|
||||
|
||||
return matcher.group(1).length()+local.unzip(unzip, ((s,p) -> s)).length()+1;
|
||||
return matcher.group(1).length()+generic.unzip(unzip, ((s,p) -> s)).length()+1;
|
||||
}
|
||||
|
||||
private static Pattern UNZIP_STICK = Pattern.compile("\\s+(?<e>[<|(|\\[|\"|'])");
|
||||
|
@ -85,12 +82,12 @@ public class Function extends OperationContainer{
|
|||
}
|
||||
}
|
||||
|
||||
private void parameters(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
private void parameters(String content, CleanerPool cleaner) throws Exception{
|
||||
if(content.length() == 1) return;
|
||||
boolean quote = false;
|
||||
do {
|
||||
Variable variable = new Variable();
|
||||
int index = variable.parse(content, global, local);
|
||||
int index = variable.parse(content, cleaner);
|
||||
this.parameters.add(variable);
|
||||
content = content.substring(index);
|
||||
quote = content.startsWith(",");
|
||||
|
|
|
@ -2,7 +2,7 @@ package be.jeffcheasey88.peeratcode.parser.java;
|
|||
|
||||
public abstract class JavaElement {
|
||||
|
||||
public abstract int parse(String content, CleanerPool global, CleanerPool local) throws Exception;
|
||||
public abstract int parse(String content, CleanerPool cleaner) throws Exception;
|
||||
|
||||
//Only for development
|
||||
public abstract void show(int tab);
|
||||
|
|
|
@ -14,7 +14,7 @@ import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
|
|||
public class JavaParser{
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\ExampleClass.java");
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\Variable.java");
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
|
||||
JavaParser parser = new JavaParser(reader);
|
||||
|
@ -105,7 +105,7 @@ public class JavaParser{
|
|||
}
|
||||
|
||||
this.clazz = new Class();
|
||||
index = this.clazz.parse(content, cleaner, null);
|
||||
index = this.clazz.parse(content, cleaner);
|
||||
content = content.substring(index);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,15 +25,13 @@ public class Variable extends JavaElement{
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
CleanerPool generic = new CleanerPool(
|
||||
new Cleaner("GENERIC_TYPE",'<','>'),
|
||||
new Cleaner("GENERIC_TYPE_",'<','>'),
|
||||
new Cleaner("GENERIC_ARRAY",'[',']'),
|
||||
new Cleaner("GENERIC_FUNCTION", '{','}'),
|
||||
new Cleaner("GENERIC_PARENTHESIS",'(',')'));
|
||||
if(local == null) local = generic;
|
||||
else local = local.group(generic);
|
||||
content = local.clean(content);
|
||||
content = generic.clean(content);
|
||||
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
@ -48,12 +46,12 @@ public class Variable extends JavaElement{
|
|||
body = body.substring(0, min);
|
||||
|
||||
if(equals < quote && equals < quotes){
|
||||
assigment(body, local);
|
||||
assigment(body, generic);
|
||||
}else{
|
||||
onlyDefine(body, local);
|
||||
onlyDefine(body, generic);
|
||||
}
|
||||
|
||||
return offset+local.unzipOne(body, (s,p) -> (p.equals("^GENERIC_TYPE") || p.equals("^GENERIC_ARRAY")) ? s : null).length();
|
||||
return offset+generic.unzip(body, ((s,p) -> s)).length();
|
||||
}
|
||||
|
||||
private void assigment(String content, CleanerPool cleaner){
|
||||
|
|
|
@ -16,12 +16,12 @@ public class AssigmentOperation extends JavaElement{
|
|||
public AssigmentOperation(){}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
this.variable = local.unzip(matcher.group(2), (s,p) -> s);
|
||||
this.value = local.unzip(matcher.group(3), (s,p) -> s);
|
||||
this.variable = matcher.group(2);
|
||||
this.value = matcher.group(3);
|
||||
|
||||
return matcher.group(1).length();
|
||||
}
|
||||
|
|
|
@ -5,11 +5,10 @@ import java.util.regex.Pattern;
|
|||
|
||||
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
|
||||
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
||||
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
|
||||
|
||||
public class ConditionalOperation extends OperationContainer{
|
||||
|
||||
private static Pattern PATTERN = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
||||
|
||||
private Pattern pattern;
|
||||
private String condition;
|
||||
|
||||
|
@ -18,29 +17,26 @@ public class ConditionalOperation extends OperationContainer{
|
|||
}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
CleanerPool generic = new CleanerPool(
|
||||
new Cleaner("GENERIC_PARENTHESIS",'(',')'),
|
||||
new Cleaner("GENERIC_FUNCTION", '{','}'));
|
||||
content = generic.clean(content);
|
||||
|
||||
Matcher matcher = this.pattern.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
this.condition = local.unzipOne(matcher.group(2), (s,p) -> s);
|
||||
|
||||
int index = matcher.group(1).length();
|
||||
content = content.substring(index);
|
||||
this.condition = generic.unzip(matcher.group(2), (s,p) -> s);
|
||||
|
||||
int index = generic.unzip(matcher.group(1), (s,p) -> s).length();
|
||||
content = generic.unzip(content, (s,p) -> s).substring(index);
|
||||
int bodysize;
|
||||
if(content.startsWith("^")){
|
||||
matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
content = matcher.group(1);
|
||||
|
||||
bodysize = content.length();
|
||||
content = local.unzipOne(content, (s,p) -> s);
|
||||
content = content.substring(1, content.length()-1);
|
||||
content = local.clean(content);
|
||||
super.parse(content, global, local);
|
||||
if(content.startsWith("{")){
|
||||
bodysize = content.indexOf('}')+1;
|
||||
content = content.substring(1, bodysize-1);
|
||||
parse(content, cleaner, generic);
|
||||
}else{
|
||||
bodysize = parseOne(content, global, local);
|
||||
bodysize = parseOne(content, cleaner, generic);
|
||||
}
|
||||
|
||||
return index+bodysize;
|
||||
|
|
|
@ -10,32 +10,30 @@ import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
|
|||
public class ElseOperation extends OperationContainer{
|
||||
|
||||
private static Pattern PATTERN = Pattern.compile("^(\\s*else\\s*).*$");
|
||||
private static Pattern PATTERN_CLEANER = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
||||
|
||||
public ElseOperation(){}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
System.out.println("ELSE STATEMENT");
|
||||
CleanerPool generic = new CleanerPool(
|
||||
new Cleaner("GENERIC_PARENTHESIS",'(',')'),
|
||||
new Cleaner("GENERIC_FUNCTION", '{','}'));
|
||||
content = generic.clean(content);
|
||||
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
int index = matcher.group(1).length();
|
||||
content = content.substring(index);
|
||||
|
||||
int index = generic.unzip(matcher.group(1), (s,p) -> s).length();
|
||||
content = generic.unzipOne(content, (s,p) -> s).substring(index);
|
||||
System.out.println("INSIDE "+content);
|
||||
int bodysize;
|
||||
if(content.startsWith("^")){
|
||||
matcher = PATTERN_CLEANER.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
content = matcher.group(1);
|
||||
|
||||
bodysize = content.length();
|
||||
content = local.unzipOne(content, (s,p) -> s);
|
||||
content = content.substring(1, content.length()-1);
|
||||
content = local.clean(content);
|
||||
super.parse(content, global, local);
|
||||
if(content.startsWith("{")){
|
||||
bodysize = content.indexOf('}')+1;
|
||||
content = content.substring(1, bodysize-1);
|
||||
parse(content, cleaner, generic);
|
||||
}else{
|
||||
bodysize = parseOne(content, global, local);
|
||||
bodysize = parseOne(content, cleaner, generic);
|
||||
}
|
||||
|
||||
return index+bodysize;
|
||||
|
|
|
@ -8,21 +8,18 @@ import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
|||
|
||||
public class MethodCallOperation extends JavaElement{
|
||||
|
||||
private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+);).*$");
|
||||
private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\(]*\\([^\\)]*\\));).*$");
|
||||
|
||||
private String value;
|
||||
|
||||
public MethodCallOperation(){}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
System.out.println("MethodCallOperation.parse -> "+content);
|
||||
content = local.clean(content);
|
||||
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
this.value = local.unzip(matcher.group(2), (s,p) -> s);
|
||||
this.value = matcher.group(2);
|
||||
|
||||
return matcher.group(1).length();
|
||||
}
|
||||
|
|
|
@ -18,30 +18,25 @@ public abstract class OperationContainer extends JavaElement{
|
|||
this.childs = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
System.out.println("OperationContainer.parse -> "+content);
|
||||
// content = local.unzipOne(content, (s,p) -> s);
|
||||
|
||||
public void parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
content = local.unzip(content, (s,p) -> s);
|
||||
System.out.println("CONTAINER "+content);
|
||||
while(!(content.replaceAll("\\s+", "").isEmpty())) content = internalParse(content, global, local);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int parseOne(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
System.out.println("OperationContainer.parseOne -> "+content);
|
||||
// content = local.unzip(content, (s,p) -> s);
|
||||
content = local.unzip(content, (s,p) -> s);
|
||||
String modify = internalParse(content, global, local);
|
||||
return content.length()-modify.length();
|
||||
}
|
||||
|
||||
private String internalParse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
System.out.println("OperationContainer.internalParse -> "+content);
|
||||
System.out.println("BODY "+content);
|
||||
|
||||
JavaElement operation = FACTORY.buildOperation(content);
|
||||
|
||||
System.out.println(operation.getClass().getSimpleName()+" operation = FACTORY.buildOperation();");
|
||||
int index = operation.parse(content, global, local);
|
||||
operation.show(0);
|
||||
System.out.println();
|
||||
System.out.println("got "+operation.getClass().getSimpleName());
|
||||
int index = operation.parse(content, local);
|
||||
content = content.substring(index);
|
||||
if(operation instanceof Variable){
|
||||
if(content.startsWith(",")){
|
||||
|
@ -54,7 +49,7 @@ public abstract class OperationContainer extends JavaElement{
|
|||
boolean quote;
|
||||
do{
|
||||
variable = new Variable(variable.getModifier(), variable.getType());
|
||||
index = variable.parse(content, global, local);
|
||||
index = variable.parse(content, local);
|
||||
multiple.addVariable(variable.getName(), variable.getValue());
|
||||
content = content.substring(index);
|
||||
quote = content.startsWith(",");
|
||||
|
|
|
@ -32,11 +32,10 @@ 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*[^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+;.*$"), MethodCallOperation.class);
|
||||
this.patterns.put(Pattern.compile("^\\s*([^;=]+;).*$"), 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -65,13 +64,15 @@ public class OperationFactory{
|
|||
*/
|
||||
|
||||
public JavaElement buildOperation(String content) throws Exception{
|
||||
System.out.println("Factory.buildOperation -> "+content);
|
||||
CleanerPool generic = new CleanerPool(
|
||||
new Cleaner("GENERIC_FUNCTION", '{','}'),
|
||||
new Cleaner("GENERIC_PARENTHESIS",'(',')'),
|
||||
new Cleaner("GENERIC_ARRAY",'[',']'),
|
||||
new Cleaner("GENERIC_TYPE_",'<','>'));
|
||||
content = generic.clean(content);
|
||||
content = generiqueTypes(content, generic);
|
||||
|
||||
System.out.println("look for "+content);
|
||||
for(Entry<Pattern, Class<? extends JavaElement>> entries : this.patterns.entrySet()){
|
||||
if(entries.getKey().matcher(content).matches()) return entries.getValue().newInstance();
|
||||
}
|
||||
|
@ -86,15 +87,25 @@ 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) -> {
|
||||
if(pattern.equals("^GENERIC_FUNCTION") || pattern.equals("^GENERIC_PARENTHESIS")) return null;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,26 +10,16 @@ public class ReturnOperation extends JavaElement{
|
|||
|
||||
private static Pattern PATTERN = Pattern.compile("^(\\s*return\\s*([^;]*);).*$");
|
||||
|
||||
private static OperationFactory FACTORY = OperationFactory.getFactory();
|
||||
|
||||
private String toChange;
|
||||
private JavaElement value;
|
||||
private String value;
|
||||
|
||||
public ReturnOperation(){}
|
||||
|
||||
@Override
|
||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||
public int parse(String content, CleanerPool cleaner) throws Exception{
|
||||
Matcher matcher = PATTERN.matcher(content);
|
||||
matcher.matches();
|
||||
|
||||
//To update for native obj
|
||||
this.toChange = matcher.group(2);
|
||||
JavaElement operation = FACTORY.buildOperation(toChange+";");
|
||||
if(operation != null){
|
||||
System.out.println(operation.getClass().getSimpleName());
|
||||
value = operation;
|
||||
value.parse(toChange+";", global, local);
|
||||
}
|
||||
this.value = matcher.group(2);
|
||||
|
||||
return matcher.group(1).length();
|
||||
}
|
||||
|
@ -38,13 +28,7 @@ public class ReturnOperation extends JavaElement{
|
|||
public void show(int tab){
|
||||
String start = "";
|
||||
for(int i = 0; i < tab; i++) start+="\t";
|
||||
if(value != null){
|
||||
System.out.println("return");
|
||||
value.show(tab+1);
|
||||
System.out.println(";");
|
||||
return;
|
||||
}
|
||||
System.out.println(start+"return "+toChange+";");
|
||||
System.out.println(start+"return "+value+";");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue