48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package be.jeffcheasey88.peeratcode.parser.java.operations;
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
|
|
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
|
|
|
public class DoOperation extends OperationContainer{
|
|
|
|
private static Pattern PATTERN = Pattern.compile("^(\\s*do\\s*).*$");
|
|
private static Pattern PATTERN_CLEANER = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
|
|
|
public DoOperation(){}
|
|
|
|
@Override
|
|
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
Matcher matcher = PATTERN.matcher(content);
|
|
matcher.matches();
|
|
|
|
int index = matcher.group(1).length();
|
|
content = content.substring(index);
|
|
|
|
matcher = PATTERN_CLEANER.matcher(content);
|
|
matcher.matches();
|
|
|
|
content = matcher.group(1);
|
|
|
|
index += 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);
|
|
|
|
return index;
|
|
}
|
|
|
|
@Override
|
|
public void show(int tab) {
|
|
String start = "";
|
|
for(int i = 0; i < tab; i++) start+="\t";
|
|
System.out.println(start+"do{");
|
|
for(JavaElement child : getChilds()) child.show(tab+1);
|
|
System.out.println(start+"}");
|
|
}
|
|
|
|
}
|
|
|