3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-01-25 03:24:01 +00:00

Add set_ast_print_mode() to Python, C#, and TypeScript bindings (#8166)

* Initial plan

* Add set_ast_print_mode to Python and PrintMode getter to C#

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add setPrintMode to TypeScript Context API

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-11 21:20:32 -08:00 committed by GitHub
parent b5492e5cf9
commit cfd40d2588
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 1 deletions

View file

@ -240,6 +240,26 @@ class Context:
def param_descrs(self):
"""Return the global parameter description set."""
return ParamDescrsRef(Z3_get_global_param_descrs(self.ref()), self)
def set_ast_print_mode(self, mode):
"""Set the pretty printing mode for ASTs.
The following modes are available:
- Z3_PRINT_SMTLIB_FULL (0): Print AST nodes in SMTLIB verbose format.
- Z3_PRINT_LOW_LEVEL (1): Print AST nodes using a low-level format.
- Z3_PRINT_SMTLIB2_COMPLIANT (2): Print AST nodes in SMTLIB 2.x compliant format.
Example:
>>> c = Context()
>>> c.set_ast_print_mode(Z3_PRINT_LOW_LEVEL)
>>> x = Int('x', c)
>>> print(x)
(Int 0)
>>> c.set_ast_print_mode(Z3_PRINT_SMTLIB2_COMPLIANT)
>>> print(x)
x
"""
Z3_set_ast_print_mode(self.ref(), mode)
# Global Z3 context