AutoTest -> 84.685%
This commit is contained in:
parent
abb21e37f2
commit
73d173ccc5
2 changed files with 22 additions and 2 deletions
|
@ -35,11 +35,20 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
public void parse(BufferedReader reader) throws Exception{
|
||||
int lineNumber = 0;
|
||||
String line;
|
||||
boolean longCommentary = false;
|
||||
while((line = reader.readLine()) != null){
|
||||
lineNumber++;
|
||||
|
||||
for(int i = 0; i < line.length(); i++){
|
||||
char c = line.charAt(i);
|
||||
if(longCommentary){
|
||||
if(c == '*' && (i < line.length()-1 && line.charAt(i+1) == '/')){
|
||||
longCommentary = false;
|
||||
i++;
|
||||
}
|
||||
System.out.print(c);
|
||||
continue;
|
||||
}
|
||||
Token token;
|
||||
if(isNameValid(c)){
|
||||
String value = "";
|
||||
|
@ -53,7 +62,11 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
i = j-1;
|
||||
}else if(Character.isWhitespace(c)) continue;
|
||||
else{
|
||||
if(c == '/' && (i == line.length()-1 || line.charAt(i+1) == '/')) break;
|
||||
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '/')) break;
|
||||
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '*')){
|
||||
longCommentary = true;
|
||||
continue;
|
||||
}
|
||||
token = new Token(lineNumber, i+1, ""+c, TokenType.DELIMITER);
|
||||
}
|
||||
getTokens().add(token);
|
||||
|
@ -131,6 +144,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
|
||||
|
||||
StateTree<JavaElement> clazz_container = new StateTree<>();
|
||||
clazz_container.then((validator) -> validator.validate((token) -> token.getValue().equals(";"))).end((a,b) -> a);
|
||||
StateTree<JavaElement> braces_container = new StateTree<>();
|
||||
|
||||
//VALUE
|
||||
|
@ -178,6 +192,9 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
StateTree<JavaElement> value_div = value_left.then((validator) -> validator.validate((token) -> token.getValue().equals("/")));
|
||||
value_div.then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
value_div.then((validator) -> validator.validate((token) -> token.getValue().equals("="))).then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
StateTree<JavaElement> value_mod = value_left.then((validator) -> validator.validate((token) -> token.getValue().equals("%")));
|
||||
value_mod.then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
value_mod.then((validator) -> validator.validate((token) -> token.getValue().equals("="))).then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
StateTree<JavaElement> value_mult = value_left.then((validator) -> validator.validate((token) -> token.getValue().equals("*")));
|
||||
value_mult.then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
value_mult.then((validator) -> validator.validate((token) -> token.getValue().equals("="))).then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).end((a,b) -> a);
|
||||
|
@ -217,6 +234,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
.then(value_array_end);
|
||||
value_array_end.end((a,b) -> a);
|
||||
value_array_end.then(value_call);
|
||||
value_array_end.then(value_array_begin);
|
||||
|
||||
StateTree<JavaElement> value_arg_begin = value_name.then((validator) -> validator.validate((token) -> token.getValue().equals("(")));
|
||||
StateTree<JavaElement> value_arg_end = value_arg_begin.then((validator) -> validator.validate((token) -> token.getValue().equals(")")));
|
||||
|
@ -315,6 +333,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
annotation_begin.then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null))).then(annotation_end);
|
||||
|
||||
StateTree<JavaElement> function_container = new StateTree<>();
|
||||
function_container.then((validator) -> validator.validate((token) -> token.getValue().equals(";"))).end((a,b) -> a);
|
||||
|
||||
//OPERATION
|
||||
StateTree<JavaElement> operation = new StateTree<>();
|
||||
|
@ -679,7 +698,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\B1PRB_Janvier2021_Oral_LhoistXavier\\src\\be\\lhoistxavier\\packet\\ClientPacket.java");
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\B2MATH-1S2122-LhoistXavier\\src\\crypto\\Adfgvx.java");
|
||||
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class GlobalCover {
|
|||
if((!hasWriten) && TokenValidator.MAX_VALIDATE < TokenValidator.TOKENS){
|
||||
parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
||||
hasWriten = true;
|
||||
System.out.println("Write of file "+file.getAbsolutePath());
|
||||
}
|
||||
|
||||
validated += TokenValidator.MAX_VALIDATE;
|
||||
|
|
Loading…
Add table
Reference in a new issue