Created
March 24, 2026 00:34
-
-
Save PaluMacil/d976ec16b65442ff34e888bfaca38082 to your computer and use it in GitHub Desktop.
xingque isn't actively updated, but it has fantastic capability to call back into Python code from the Starlark code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from xingque import AstModule, GlobalsBuilder, Evaluator | |
| def foo(): | |
| return 88 | |
| def main(): | |
| text = """ | |
| def square(x): | |
| return x * x | |
| a = 42 | |
| b = square(a) | |
| z = b + 1 + int(bool(233)) | |
| foo() | |
| """ | |
| ast = AstModule.parse("test.star", text) | |
| gb = GlobalsBuilder.standard() | |
| gb.set("foo", foo) | |
| g = gb.build() | |
| e = Evaluator() | |
| result = e.eval_module(ast, g) | |
| print(type(result)) | |
| print(result) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment