Reputation: 43
I have several Hy Lang code snippets that I use in my python project. I was wondering if there is a relatively easy way for me to get an Abstract Syntax Tree of the Hy code with some python library or maybe even the Hy compiler itself (I've looked into the compiler code but I'm having a hard time understanding it).
I know that Hy transforms all the Hy lang code to a python AST before making that bytecode and looking at the compiler I do not see a function that would help me convert the Hy code to a Hy object that I can feed to HyASTCompiler for example.
I'm hoping I can leverage something already built and not have to use something like ANTLER and write my own grammar.
Thanks!
Using Hy Version 0.12 and python3
Upvotes: 0
Views: 119
Reputation: 3495
I'm not clear if you want Python ast
objects or just Hy code as data. The latter is provided by hy.read
and hy.read-many
. For the former, no public interface is currently provided, but take a look at the docstring of the internal function hy.compiler.hy_compile
.
Hy 0.12 is ancient, though, so you'll probably need to upgrade.
Upvotes: 1