문제

Is it possible to take a quoted Elixir expression (AST tree) like this:

quote do: 1 + 1
=> {:+, [context: Elixir, import: Kernel], [1, 1]}

And convert it to an Erlang AST?

I looked through the Code module as well as some of the Kernel modules looking for a function that did this but I didn't find anything. I am not even sure if this would be possible... I don't know how things like Elixir macros would be represented in Erlang AST.

Thanks in advance!

도움이 되었습니까?

해결책

There isn't currently a public API to do so. You could look into the elixir module to know how it is done but it is private API and it can be changed any time with no guarantee of compatibility, or even removed.

다른 팁

For example I wrote 'gist' how it can be done - https://gist.github.com/habibutsu/bc6791d3d81b6ea54e1a

There are used two functions:

fun elixir:'string_to_quoted!'/4
fun elixir:quoted_to_erl/3
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top