Little fixes
This commit is contained in:
parent
71f0c46b00
commit
111eecd929
3 changed files with 35 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
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;
|
||||||
|
@ -30,6 +31,8 @@ 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){
|
||||||
|
|
|
@ -175,10 +175,17 @@ 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"));
|
//
|
||||||
bag.set(result);
|
// BiValue result = new BiValue(
|
||||||
}
|
//
|
||||||
|
// bag.get("left"),
|
||||||
|
//
|
||||||
|
// bag.get("action"),
|
||||||
|
//
|
||||||
|
// bag.get("right"));
|
||||||
|
// bag.set(result);
|
||||||
|
// }
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -443,7 +450,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<>(ValueTests.get(), (global, local) -> {
|
.then(new RedirectStateTree<>(value, (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<>();
|
||||||
|
@ -497,7 +504,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(";")))
|
||||||
|
@ -1000,21 +1007,21 @@ public class JavaParser extends Parser<JavaElement> {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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\\Eclipse_Lhoist_Xavier_plan2Track_IT1\\app\\src\\main\\java\\be\\helmo\\plan2track\\planner\\domain\\Assembly.java");
|
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));
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
//
|
|
||||||
// time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
//
|
|
||||||
// Parser<JavaElement> parser = new JavaParser();
|
Parser<JavaElement> parser = new JavaParser();
|
||||||
// JavaElement jFile = new JavaElement();
|
JavaFile jFile = new JavaFile();
|
||||||
// parser.parse(reader, jFile);
|
parser.parse(reader, jFile);
|
||||||
//
|
|
||||||
// System.out.println((System.currentTimeMillis()-time)+"ms");
|
System.out.println((System.currentTimeMillis()-time)+"ms");
|
||||||
//
|
|
||||||
// System.out.println(TokenValidator.MAX_VALIDATE+" / "+TokenValidator.TOKENS);
|
System.out.println(TokenValidator.MAX_VALIDATE+" / "+TokenValidator.TOKENS);
|
||||||
//
|
|
||||||
// parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
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;
|
||||||
|
@ -25,6 +26,7 @@ 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){
|
||||||
|
|
Loading…
Add table
Reference in a new issue