Compare commits

..

No commits in common. "111eecd929bdf77fa540b2259a5dbcc87d4127b0" and "12d9f5b6cd258254f969322eb2b9596c3f06bd56" have entirely different histories.

4 changed files with 11 additions and 29 deletions

View file

@ -1,6 +1,5 @@
package be.jeffcheasey88.peeratcode.parser.java; package be.jeffcheasey88.peeratcode.parser.java;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.Token;
@ -31,8 +30,6 @@ public class Function extends JavaElement implements Annotable, VariableContaine
this.mod = mod; this.mod = mod;
this.type = type; this.type = type;
this.name = name; this.name = name;
this.annotations = new ArrayList<>();
this.elements = new ArrayList<>();
} }
public Function(int mod, Token generic, Token type, Token name){ public Function(int mod, Token generic, Token type, Token name){

View file

@ -175,17 +175,10 @@ public class JavaParser extends Parser<JavaElement> {
//VALUE //VALUE
BiFunction<JavaElement, Bag, JavaElement> value_builder = (parent, bag) -> { BiFunction<JavaElement, Bag, JavaElement> value_builder = (parent, bag) -> {
// if(bag.has("right")){ if(bag.has("right")){
// BiValue result = new BiValue(bag.get("left"), bag.get("action"), bag.get("right"));
// BiValue result = new BiValue( bag.set(result);
// }
// bag.get("left"),
//
// bag.get("action"),
//
// bag.get("right"));
// bag.set(result);
// }
return null; return null;
}; };
@ -450,7 +443,7 @@ public class JavaParser extends Parser<JavaElement> {
(token) -> token.getType().equals(TokenType.NAME), (token) -> token.getType().equals(TokenType.NAME),
(bag, token) -> bag.set("index", token))); (bag, token) -> bag.set("index", token)));
StateTree<JavaElement> annotation_value = annotation_var.then((validator) -> validator.validate((token) -> token.getValue().equals("="))) StateTree<JavaElement> annotation_value = annotation_var.then((validator) -> validator.validate((token) -> token.getValue().equals("=")))
.then(new RedirectStateTree<>(value, (global, local) -> { .then(new RedirectStateTree<>(ValueTests.get(), (global, local) -> {
Map<Token, Value> map = global.get("values"); Map<Token, Value> map = global.get("values");
if(map == null){ if(map == null){
map = new LinkedHashMap<>(); map = new LinkedHashMap<>();
@ -504,7 +497,7 @@ public class JavaParser extends Parser<JavaElement> {
variable_split.then(variable_name); variable_split.then(variable_name);
StateTree<JavaElement> variable_value = variable_name.then((validator) -> validator.validate((token) -> token.getValue().equals("="))) StateTree<JavaElement> variable_value = variable_name.then((validator) -> validator.validate((token) -> token.getValue().equals("=")))
.then(new RedirectStateTree<>(value_container, (global, local) -> { .then(new RedirectStateTree<>(value_container, (global, local) -> {
// global.<Map<Token, Value>>get("vars").put(global.get("last"), local.get()); global.<Map<Token, Value>>get("vars").put(global.get("last"), local.get());
})); }));
variable_value.then(variable_split); variable_value.then(variable_split);
variable_value.then((validator) -> validator.validate((token) -> token.getValue().equals(";"))) variable_value.then((validator) -> validator.validate((token) -> token.getValue().equals(";")))
@ -928,10 +921,7 @@ public class JavaParser extends Parser<JavaElement> {
return validator.validate((token) -> token.getValue().equals(";")); return validator.validate((token) -> token.getValue().equals(";"));
} }
return false; return false;
}).<JavaElement>end((parent, bag) -> { }).<JavaElement>end((javafile, bag) -> javafile);
((JavaFile)parent).addImport(bag);
return parent;
});
InitialStateTree<JavaElement> main = new InitialStateTree<>(); InitialStateTree<JavaElement> main = new InitialStateTree<>();
@ -949,10 +939,7 @@ public class JavaParser extends Parser<JavaElement> {
return validator.validate((token) -> token.getValue().equals(";")); return validator.validate((token) -> token.getValue().equals(";"));
} }
return false; return false;
}).end((parent, bag) -> { }).end((javafile, bag) -> javafile);
((JavaFile)parent).setPackage(bag);
return parent;
});
main.multiple(pack); main.multiple(pack);
main.multiple(importState); main.multiple(importState);
main.multiple(annotation); main.multiple(annotation);
@ -1008,14 +995,14 @@ public class JavaParser extends Parser<JavaElement> {
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\dev\\peerat\\backend\\Configuration.java"); File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\Eclipse_Lhoist_Xavier_plan2Track_IT1\\app\\src\\main\\java\\be\\helmo\\plan2track\\planner\\domain\\Assembly.java");
BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));
time = System.currentTimeMillis(); time = System.currentTimeMillis();
Parser<JavaElement> parser = new JavaParser(); Parser<JavaElement> parser = new JavaParser();
JavaFile jFile = new JavaFile(); JavaElement jFile = new JavaElement();
parser.parse(reader, jFile); parser.parse(reader, jFile);
System.out.println((System.currentTimeMillis()-time)+"ms"); System.out.println((System.currentTimeMillis()-time)+"ms");

View file

@ -1,6 +1,5 @@
package be.jeffcheasey88.peeratcode.parser.java; package be.jeffcheasey88.peeratcode.parser.java;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.Token;
@ -26,7 +25,6 @@ public class Variable extends JavaElement implements Annotable{
this.mod = mod; this.mod = mod;
this.type = type; this.type = type;
this.name = name; this.name = name;
this.annotations = new ArrayList<>();
} }
public Variable(int mod, Token type, Token name, boolean elips){ public Variable(int mod, Token type, Token name, boolean elips){