To understand the output of Code.string_to_quoted, you may find it interesting to learn more about “quoted expressions”. That’s related to the AST representation of Elixir source code. See https://elixir-lang.org/getting-started/meta/quote-and-unquote.html. It is an advanced topic that requires some time to master, at least that was my personal experience ![]()
If I follow correctly, you want to filter out vast parts of Elixir, such as function invocations (., |>, among other variants) and maybe more. I would recommend thinking in terms of a whitelist instead. You may want to start allowing code that consists only in identifier names (represented as plain atoms in the AST) and some basic operators such as and, or, >, and so. You can play with iex to get familiar with the AST associated with elementary forms of Elixir code (the ones you could start supporting, if possible).
In any case, it is not easy to work with this stuff. I agree with the fact that it is very error-prone.


















