and foreach...
This commit is contained in:
parent
ae4e74874c
commit
2740382354
2 changed files with 38 additions and 2 deletions
|
@ -539,8 +539,35 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
|
||||
StateTree<JavaElement> operation_for_first_part = operation_for.then((validator) -> validator.validate((token) -> token.getValue().equals(";")));
|
||||
|
||||
|
||||
StateTree<JavaElement> operation_for_assign = operation_for.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
StateTree<JavaElement> operation_for_assign_end = operation_for_assign.then((validator) -> validator.validate((token) -> token.getValue().equals("=")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
|
||||
operation_for_assign.then(operation_for_assign);
|
||||
operation_for_assign.then(operation_for_first_part);
|
||||
|
||||
|
||||
operation_for_assign_end.then((validator) -> validator.validate((token) -> token.getValue().equals(",")))
|
||||
.then(operation_for_assign);
|
||||
operation_for_assign_end.then(operation_for_first_part);
|
||||
|
||||
|
||||
StateTree<JavaElement> operation_for_second_part = operation_for_first_part.then((validator) -> validator.validate((token) -> token.getValue().equals(";")));
|
||||
|
||||
operation_for_first_part.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
|
||||
.then(operation_for_second_part);
|
||||
|
||||
StateTree<JavaElement> operation_for_end = operation_for_second_part.then((validator) -> validator.validate((token) -> token.getValue().equals(")")));
|
||||
operation_for_end.end((a,b) -> a);
|
||||
|
||||
operation_for_assign.then((validator) -> validator.validate((token) -> token.getValue().equals(":")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
|
||||
.then(operation_for_end);
|
||||
|
||||
operation_for_second_part.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
|
||||
.then(operation_for_end);
|
||||
|
||||
StateTree<JavaElement> operation_while = operation.then((validator) -> validator.validate((token) -> token.getValue().equals("while")))
|
||||
.then((validator) -> validator.validate((token) -> token.getValue().equals("(")))
|
||||
.then(new RedirectStateTree<>(value_container, (global, local) -> global.set(null)))
|
||||
|
|
|
@ -45,6 +45,10 @@ public class ForCase {
|
|||
StateTree<JavaElement> operation_for_end = operation_for_second_part.then((validator) -> validator.validate((token) -> token.getValue().equals(")")));
|
||||
operation_for_end.end((a,b) -> a);
|
||||
|
||||
operation_for_assign.then((validator) -> validator.validate((token) -> token.getValue().equals(":")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
|
||||
.then(operation_for_end);
|
||||
|
||||
operation_for_second_part.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
|
||||
.then(operation_for_end);
|
||||
|
||||
|
@ -115,4 +119,9 @@ public class ForCase {
|
|||
void case10() throws Exception{
|
||||
testCase("for(private static final int i=4,k;value;)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void case11() throws Exception{
|
||||
testCase("for(Test test : tests)");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue