Skip to content
Snippets Groups Projects
Commit 69d7bf47 authored by Johannes Mey's avatar Johannes Mey
Browse files

work on parser

parent ae2df97e
Branches
No related tags found
No related merge requests found
Pipeline #13404 failed
...@@ -27,7 +27,7 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { ...@@ -27,7 +27,7 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
while (true) { while (true) {
peekObjectAtWrongPlace(); peekObjectAtWrongPlace();
if (peekedObjectAtWrongPlace_ != null) { if (peekedObjectAtWrongPlace_ != null) {
parseObjectAtWrongPlace(result.getMoveObjectToCorrectPlaceList(), result.getNumMoveObjectToCorrectPlace()); parseMoveObjectToCorrectPlace(result.getMoveObjectToCorrectPlaceList(), result.getNumMoveObjectToCorrectPlace());
} else { } else {
break; break;
} }
...@@ -41,6 +41,84 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { ...@@ -41,6 +41,84 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
printAST("parseTidy", result); printAST("parseTidy", result);
} }
private void parseMoveObjectToCorrectPlace(ASTNode<?> parent, int index) throws ParseException {
MoveObjectToCorrectPlace result = (MoveObjectToCorrectPlace) parent.getChild(index);
parseObjectAtWrongPlace(result, 0);
parsePickUpObject(result, 1);
parseDropObjectAtRightPlace(result, 2);
// semantic action for T1
result.action(getWorld());
printAST("parseMoveObjectToCorrectPlace", result);
}
private void parseDropObjectAtRightPlace(ASTNode<?> parent, int index) throws ParseException {
DropObjectAtRightPlace result = (DropObjectAtRightPlace) parent.getChild(index);
parseRightPlace(result, 0);
parseDrop(result, 1);
// semantic action for T1
result.action(getWorld());
printAST("parseDropObjectAtRightPlace", result);
}
private void parsePickUpObject(ASTNode<?> parent, int index) throws ParseException {
PickUpObject result = (PickUpObject) parent.getChild(index);
parseRobotIsReadyToPick(result, 0);
parsePick(result, 1);
// semantic action for T1
result.action(getWorld());
printAST("parsePickUpObject", result);
}
private void parseRobotIsReadyToPick(ASTNode<?> parent, int index) throws ParseException {
RobotIsReadyToPick result;
// try to parse a T
if (peekRobotIsFree()) {
result = new RobotIsReallyReadyToPick();
parent.setChild(result, index);
parseRobotIsReallyReadyToPick(parent, index);
} else if (peekRobotIsBusy()) {
result = new RobotIsNotReadyToPick();
parent.setChild(result, index);
parseRobotIsNotReadyToPick(parent, index);
} else {
throw new ParseException("RobotIsReadyToPick", RobotIsFree.type(), RobotIsBusy.type());
}
// semantic action for T1
result.action(getWorld());
printAST("parsePickUpObject", result);
}
private void parseRobotIsReallyReadyToPick(ASTNode<?> parent, int index) throws ParseException {
RobotIsReallyReadyToPick result = (RobotIsReallyReadyToPick) parent.getChild(index);
parseRobotIsFree(result, 0);
// semantic action for T1
result.action(getWorld());
printAST("parseRobotIsReallyReadyToPick", result);
}
private void parseRobotIsNotReadyToPick(ASTNode<?> parent, int index) throws ParseException {
RobotIsNotReadyToPick result = (RobotIsNotReadyToPick) parent.getChild(index);
parseRobotIsBusy(result, 0);
parseWait(result, 1);
parseRobotIsReadyToPick(result, 2);
// semantic action for T1
result.action(getWorld());
printAST("parseRobotIsNotReadyToPick", result);
}
private boolean peekObjectAtWrongPlace() { private boolean peekObjectAtWrongPlace() {
peekedObjectAtWrongPlace_ = getWorld().parseObjectAtWrongPlace(); peekedObjectAtWrongPlace_ = getWorld().parseObjectAtWrongPlace();
return peekedObjectAtWrongPlace_ != null; return peekedObjectAtWrongPlace_ != null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment