Parsing String into Elixir AST

Is there a function in the elixir standard library that can parse a strong into an Elixir AST? I don’t want the AST to be compiled or evaluated, I just want access to the AST. Thanks :slight_smile:

1 Like

@tmbb: Yes, there is: &Code.string_to_quoted/2

Example:

code = ~s/String.downccase("something")/
Code.string_to_quoted(code)             
{:ok,
 {{:., [line: 1],
   [{:__aliases__, [counter: 0, line: 1], [:String]}, :downccase]}, [line: 1],
  ["something"]}}
4 Likes

Thanks, I’ve read the Code module supposedly cover-to-cover about three times and still missed it…