37 lines
978 B
Java
37 lines
978 B
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 AssigmentOperation extends JavaElement{
|
|
|
|
private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\s]+)\\s*=\\s*([^;]+);).*$");
|
|
|
|
private String variable;
|
|
private String value;
|
|
|
|
public AssigmentOperation(){}
|
|
|
|
@Override
|
|
public int parse(String content, CleanerPool global, CleanerPool local) 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);
|
|
|
|
return matcher.group(1).length();
|
|
}
|
|
|
|
@Override
|
|
public void show(int tab){
|
|
String start = "";
|
|
for(int i = 0; i < tab; i++) start+="\t";
|
|
System.out.println(start+variable+" = "+value+";");
|
|
}
|
|
|
|
|
|
}
|