Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Convert a UAST into Python AST #91

Open
pcyin opened this issue Mar 30, 2018 · 7 comments
Open

Convert a UAST into Python AST #91

pcyin opened this issue Mar 30, 2018 · 7 comments

Comments

@pcyin
Copy link

pcyin commented Mar 30, 2018

Hi. I am new to bblfsh and was wondering if I could convert a UAST into Python's AST structure defined by the ast module. Thanks!

@dennwc
Copy link
Member

dennwc commented Mar 30, 2018

Hi @pcyin. The short answer: it's not possible at the moment.

Can you share more information about your use case?

It looks like you are parsing Python sources (since you want python AST at the end) from Python (since you are using this client). If it's the only use case, it will be easier for you to use Python parser itself, without Babelfish server.

On the other hand, if you want to convert any AST to Python AST, then the problem is on a totally different level. We are currently working on a new implementation of UAST that might make this conversion possible.

@juanjux
Copy link
Contributor

juanjux commented Mar 30, 2018

If the problem is getting the Python AST you can use ParseNative instead of parse.

@dennwc
Copy link
Member

dennwc commented Mar 30, 2018

@juanjux But it will not be directly compatible with Python's ast module in this case.

@juanjux
Copy link
Contributor

juanjux commented Mar 30, 2018

It's the same structure with added positions in some cases and json format.

@dennwc
Copy link
Member

dennwc commented Mar 30, 2018

Sure, the structure is the same, but these object will not be of a class ast.AST defined in mentioned Python module. This might make a difference in some cases.

@bzz
Copy link
Contributor

bzz commented Jan 24, 2019

Closing, as the question seems to be answered and there is no further discussion.
But please, feel free to re-open if that is not the case.

@dennwc
Copy link
Member

dennwc commented Jan 29, 2019

I think it's relevant, but it should be addressed in SDK first:
bblfsh/sdk#352

@dennwc dennwc reopened this Jan 29, 2019
@bzz bzz added enhancement and removed question labels Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants