Open tadamcz opened 1 year ago
I think this might be possible to some degree, but we aren't using any part of the API that would give us something like this at the moment. I will keep this in mind as I am looking at the starlark-go API docs to implement some other things.
Ok, thanks! To clarify, do you know if there is an API for this in starlark-go
? (Obviously they have the machinery for this internally, my question is if there's a reasonably "public-facing" API e.g. with docs).
@tadamcz Yeah I think the 'syntax` package is what you'd be looking for: https://pkg.go.dev/go.starlark.net@v0.0.0-20230302034142-4b1e35fe2254/syntax
Great library, thanks so much for your work! I really appreciate e.g. how you've translated exceptions in a way that lets you easily access the line and column number of a Starlark error 👌.
Does Starlark provide a way to access the syntax tree of an expression? Is this something we could add to
python-starlark-go
? (If Starlark exposes the tree I'm happy to take a shot at it, but my go skills are very poor).So, for example, in the Starlark code:
we could access the fact that
result
depends onb
andc
via the operator+
, and in turnc
depends ona
(and a literal) via*
.