Skip to content

Commit

Permalink
#40: ShowTerm transform AST directly
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanzwicknagl committed Dec 21, 2023
1 parent 748c8ee commit ff5af65
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions backend/src/viasp/asp/reify.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,22 @@ def get_body_aggregate_elements(self, body: Sequence[AST]) -> List[AST]:
def visit_ShowTerm(self, showTerm: AST):
if (hasattr(showTerm, "location") and isinstance(showTerm.location, ast.Location)
and hasattr(showTerm, "term") and isinstance(showTerm.term, AST)
and hasattr(showTerm.term, "symbol") and isinstance(showTerm.term.symbol, clingo.symbol.Symbol)
and hasattr(showTerm.term.symbol, "name") and isinstance(showTerm.term.symbol.name, str)
and hasattr(showTerm.term.symbol, "arguments") and isinstance(showTerm.term.symbol.arguments, Sequence)
and hasattr(showTerm, "body") and isinstance(showTerm.body, Sequence)
and all(isinstance(elem, AST) for elem in showTerm.body)):
new_head = ast.Literal(
showTerm.location,
ast.Sign.NoSign,
ast.SymbolicAtom(
showTerm.term
)
ast.Function(
showTerm.location,
showTerm.term.symbol.name,
cast(Sequence, showTerm.term.symbol.arguments),
0
)
)
)
self.visit(
ast.Rule(
Expand Down

0 comments on commit ff5af65

Please sign in to comment.