diff --git a/src/main/resources/template-configs/RobotParser.yaml b/src/main/resources/template-configs/RobotParser.yaml index 45e1c588ff7460492aed3b5ead8e7cc138b0e67d..b272fbddd2d1ca22d1979c6f84d2cc98958fc5b0 100644 --- a/src/main/resources/template-configs/RobotParser.yaml +++ b/src/main/resources/template-configs/RobotParser.yaml @@ -4,14 +4,14 @@ genPackage: "de.tudresden.inf.st.mg.jastadd.model" targetType: "Tidy" tokenContext: - context: false # default value + contextType: false # default value peek: true # default value worldParserArguments: [ ] # default value tokens: - name: "EmptyTable" - name: "NotEmptyTable" - - name: "ObjectAtWrongPlace" - context: "Tidy" + - name: "AvailableObject" + contextType: "Tidy" - name: "RobotIsReadyToPickToken" - name: "RobotIsNotReadyToPickToken" - name: "RobotIsReadyToDropToken" @@ -26,8 +26,9 @@ tokenContext: peek: false - name: "RightPlace" worldParserArguments: - - argument: "object()" + - argument: "object()" peek: false + - name: "MisplacedObject" ruleContext: constructObject: false # default value @@ -47,7 +48,7 @@ ruleContext: peekToken: "EmptyTable" - componentName: "MoveObjectToCorrectPlace" list: true - peekToken: "ObjectAtWrongPlace" + peekToken: "MisplacedObject" peekContext: "result" - componentName: "WaitForEmptyTable" list: true @@ -57,7 +58,7 @@ ruleContext: - ruleName: "MoveObjectToCorrectPlace" constructObject: true components: - - componentName: "ObjectAtWrongPlace" + - componentName: "MisplacedObject" token: true index: 0 additionalArgs: ", parent.containingTidy()" @@ -88,9 +89,6 @@ ruleContext: components: - componentName: "RobotIsReadyToDrop" index: 0 - - componentName: "RightPlace" - token: true - index: 1 - ruleName: "PickUpObject" constructObject: true components: diff --git a/src/main/resources/templates/Parser.mustache b/src/main/resources/templates/Parser.mustache index bd3b6b615ba592f18f0d627f44162203e7e16db1..6ae7039b5b41e1dca15e96416544352c5e2d2ca6 100644 --- a/src/main/resources/templates/Parser.mustache +++ b/src/main/resources/templates/Parser.mustache @@ -26,13 +26,13 @@ public final class {{{name}}} extends MotionGrammarParser<{{{targetType}}}> { {{#peek}} private {{{name}}} peeked{{{name}}}_ = null; - private boolean peek{{{name}}}({{#context}}{{{context}}} context{{/context}}) { - peeked{{{name}}}_ = getWorld().parse{{{name}}}({{#context}}context{{/context}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); + private boolean peek{{{name}}}({{#contextType}}{{{contextType}}} context{{/contextType}}) { + peeked{{{name}}}_ = getWorld().parse{{{name}}}({{#contextType}}context{{/contextType}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); return peeked{{{name}}}_ != null; } {{/peek}} - private void parse{{{name}}}(ASTNode<?> parent, int index{{#context}}, {{{context}}} context{{/context}}) throws ParseException { + private void parse{{{name}}}(ASTNode<?> parent, int index{{#contextType}}, {{{contextType}}} context{{/contextType}}) throws ParseException { {{{name}}} result; {{#peek}} @@ -40,14 +40,14 @@ public final class {{{name}}} extends MotionGrammarParser<{{{targetType}}}> { result = peeked{{{name}}}_; peeked{{{name}}}_ = null; // TODO check if all peeked values are actually parsed afterwards } else { - result = getWorld().parse{{{name}}}({{#context}}context{{/context}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); + result = getWorld().parse{{{name}}}({{#contextType}}context{{/contextType}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); if (result == null) { throw new ParseException({{{name}}}.type()); } } {{/peek}} {{^peek}} - result = getWorld().parse{{{name}}}({{#context}}context{{/context}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); + result = getWorld().parse{{{name}}}({{#contextType}}context{{/contextType}}{{#worldParserArguments}}parent.{{{argument}}}{{/worldParserArguments}}); if (result == null) { throw new ParseException({{{name}}}.type()); }