Little fixes

This commit is contained in:
jeffcheasey88 2023-10-15 11:40:14 +02:00
parent 71f0c46b00
commit 111eecd929
3 changed files with 35 additions and 23 deletions

View file

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

View file

@ -175,10 +175,17 @@ public class JavaParser extends Parser<JavaElement> {
//VALUE
BiFunction<JavaElement, Bag, JavaElement> value_builder = (parent, bag) -> {
if(bag.has("right")){
BiValue result = new BiValue(bag.get("left"), bag.get("action"), bag.get("right"));
bag.set(result);
}
// if(bag.has("right")){
//
// BiValue result = new BiValue(
//
// bag.get("left"),
//
// bag.get("action"),
//
// bag.get("right"));
// bag.set(result);
// }
return null;
};
@ -443,7 +450,7 @@ public class JavaParser extends Parser<JavaElement> {
(token) -> token.getType().equals(TokenType.NAME),
(bag, token) -> bag.set("index", token)));
StateTree<JavaElement> annotation_value = annotation_var.then((validator) -> validator.validate((token) -> token.getValue().equals("=")))
.then(new RedirectStateTree<>(ValueTests.get(), (global, local) -> {
.then(new RedirectStateTree<>(value, (global, local) -> {
Map<Token, Value> map = global.get("values");
if(map == null){
map = new LinkedHashMap<>();
@ -497,7 +504,7 @@ public class JavaParser extends Parser<JavaElement> {
variable_split.then(variable_name);
StateTree<JavaElement> variable_value = variable_name.then((validator) -> validator.validate((token) -> token.getValue().equals("=")))
.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((validator) -> validator.validate((token) -> token.getValue().equals(";")))
@ -1000,21 +1007,21 @@ public class JavaParser extends Parser<JavaElement> {
return 0;
}
// public static void main(String[] args) throws Exception{
// 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));
//
// time = System.currentTimeMillis();
//
// Parser<JavaElement> parser = new JavaParser();
// JavaElement jFile = new JavaElement();
// parser.parse(reader, jFile);
//
// System.out.println((System.currentTimeMillis()-time)+"ms");
//
// System.out.println(TokenValidator.MAX_VALIDATE+" / "+TokenValidator.TOKENS);
//
// parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
// }
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");
BufferedReader reader = new BufferedReader(new FileReader(file));
time = System.currentTimeMillis();
Parser<JavaElement> parser = new JavaParser();
JavaFile jFile = new JavaFile();
parser.parse(reader, jFile);
System.out.println((System.currentTimeMillis()-time)+"ms");
System.out.println(TokenValidator.MAX_VALIDATE+" / "+TokenValidator.TOKENS);
parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
}
}

View file

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