Skip to content

Conversation

@Premwoik
Copy link
Collaborator

@Premwoik Premwoik commented Dec 7, 2021

This PR adds a module to pretty print abstract code expressions in Elixir code.

Done in this PR

Checklist:

  • Support basic expressions
  • Support struct printing
  • Support expressions that have clauses (try, case, receive)
  • Support raise
  • Support reraise
  • Support block
  • Support if printing (It is represented as a case in abstract format)
  • Support cond printing (It is represented as a case in abstract format)
  • Add guard support
  • Support binary comprehension
  • Support bitstring constructor
  • Test it as much as possible (test coverage is 100%)

Other fixes:

  • Fix an unknown type pointed out by the dialyzer (Gradient.Debug).

Investigate:

  • nil ([]) line is not specified by AstSpecifier.

No need to cover

  • if expression / not used by Elixir (Elixir uses case in abstract code)
  • record / not used by Elixir, probably can be skipped
  • catch / not produced by Elixir, I think

Possible further work:

  • Support with printing (It is represented as a case in abstract format)
  • Support pipe (Maybe print nested calls as a pipe for more than 2 nestings?)
  • Support proper sigil printing e.g ~T[23:00:07.0] (Currently struct is printed)
  • List comprehension (It is an Enum.reduce call stored in abstract format)
  • Skip printing :erlang. before functions available globally in Elixir e.g. :erlang.is_list

@Premwoik Premwoik changed the title Expr pp Elixir Expressions elixir pp Dec 7, 2021
@Premwoik Premwoik marked this pull request as ready for review January 27, 2022 12:22
@Premwoik Premwoik requested a review from erszcz January 27, 2022 12:22
Copy link
Contributor

@erszcz erszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, that was a whole lot of work! Great! I left a few comments or questions, but they're cosmetic.

@erszcz
Copy link
Contributor

erszcz commented Feb 2, 2022

It's awesome 🎉

@erszcz erszcz merged commit 4c4ac7e into main Feb 2, 2022
@erszcz erszcz deleted the expr-elixir-pp branch February 2, 2022 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants