Exemple #1
0
 def walk_fluent_exp(self, expression: model.FNode,
                     args: List[proto.Expression]) -> proto.Expression:
     sub_list = []
     sub_list.append(
         proto.Expression(
             atom=proto.Atom(symbol=expression.fluent().name),
             kind=proto.ExpressionKind.Value("FLUENT_SYMBOL"),
             type=str(expression.fluent().type),
         ))
     sub_list.extend(args)
     return proto.Expression(
         atom=None,
         list=sub_list,
         kind=proto.ExpressionKind.Value("STATE_VARIABLE"),
         type=str(expression.fluent().type),
     )
Exemple #2
0
 def walk_int_constant(self, expression: model.FNode,
                       args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(int=expression.int_constant_value()),
         list=[],
         kind=proto.ExpressionKind.Value("CONSTANT"),
         type="integer",
     )
Exemple #3
0
 def walk_bool_constant(self, expression: model.FNode,
                        args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(boolean=expression.bool_constant_value()),
         list=[],
         kind=proto.ExpressionKind.Value("CONSTANT"),
         type="bool",
     )
Exemple #4
0
 def walk_object_exp(self, expression: model.FNode,
                     args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(symbol=expression.object().name),
         list=[],
         kind=proto.ExpressionKind.Value("CONSTANT"),
         type=str(expression.object().type),
     )
Exemple #5
0
 def walk_variable_exp(self, expression: model.FNode,
                       args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(symbol=expression.variable().name),
         list=[],
         kind=proto.ExpressionKind.Value("VARIABLE"),
         type=str(expression.variable().type),
     )
Exemple #6
0
 def walk_param_exp(self, expression: model.FNode,
                    args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(symbol=expression.parameter().name),
         list=[],
         kind=proto.ExpressionKind.Value("PARAMETER"),
         type=str(expression.parameter().type),
     )
Exemple #7
0
 def walk_real_constant(self, expression: model.FNode,
                        args: List[proto.Expression]) -> proto.Expression:
     return proto.Expression(
         atom=proto.Atom(real=self._protobuf_writer.convert(
             expression.real_constant_value())),
         list=[],
         kind=proto.ExpressionKind.Value("CONSTANT"),
         type="real",
     )
Exemple #8
0
 def _convert_expression_variable(
         self, variable: model.Variable) -> proto.Expression:
     # a variable declaration (in forall/exists) is converted directly as an expression
     return proto.Expression(
         atom=proto.Atom(symbol=variable.name),
         list=[],
         kind=proto.ExpressionKind.Value("VARIABLE"),
         type=str(variable.type),
     )
Exemple #9
0
    def walk_operator(self, expression: model.FNode,
                      args: List[proto.Expression]) -> proto.Expression:
        sub_list = []
        sub_list.append(
            proto.Expression(
                atom=proto.Atom(symbol=map_operator(expression.node_type)),
                list=[],
                kind=proto.ExpressionKind.Value("FUNCTION_SYMBOL"),
                type="",
            ))
        # forall/exists: add the declared variables from the payload to the beginning of the parameter list.
        if expression.is_exists() or expression.is_forall():
            sub_list.extend([
                self._protobuf_writer.convert(p)
                for p in expression.variables()
            ])

        sub_list.extend(args)
        return proto.Expression(
            atom=None,
            list=sub_list,
            kind=proto.ExpressionKind.Value("FUNCTION_APPLICATION"),
            type="",
        )