fix: Conversion goals and value printing

This commit is contained in:
Leni Aniva 2024-04-22 13:32:29 -07:00
parent 8658ec08e2
commit 6091a5191c
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 6 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class Variable:
result = self.name if self.name else "_" result = self.name if self.name else "_"
result += f" : {self.t}" result += f" : {self.t}"
if self.v: if self.v:
result += f" = {self.v}" result += f" := {self.v}"
return result return result
@dataclass(frozen=True) @dataclass(frozen=True)
@ -36,6 +36,7 @@ class Goal:
variables: list[Variable] variables: list[Variable]
target: Expr target: Expr
name: Optional[str] = None name: Optional[str] = None
is_conversion: bool = False
@staticmethod @staticmethod
def sentence(target: Expr) -> Self: def sentence(target: Expr) -> Self:
@ -46,11 +47,13 @@ class Goal:
name = payload.get("userName") name = payload.get("userName")
variables = [Variable._parse(v) for v in payload["vars"]] variables = [Variable._parse(v) for v in payload["vars"]]
target = parse_expr(payload["target"]) target = parse_expr(payload["target"])
return Goal(variables, target, name) is_conversion = payload["isConversion"]
return Goal(variables, target, name, is_conversion)
def __str__(self): def __str__(self):
front = "|" if self.is_conversion else ""
return "\n".join(str(v) for v in self.variables) + \ return "\n".join(str(v) for v in self.variables) + \
f"\n {self.target}" f"\n{front} {self.target}"
@dataclass(frozen=True) @dataclass(frozen=True)
class GoalState: class GoalState: