Skip to content

Conversation

@Premwoik
Copy link
Collaborator

@Premwoik Premwoik commented Apr 1, 2022

This resolves #9 and finally handles specifying location with the tokens in the pipe operator.

Before

image

Now

image

Solution

Added a check to the call mapper if the first token is a |>. If true and if the first call arg is a lineless expression (an expression that could be without location) then the line in opts is set to 0. Thus the tokens before this call line are not dropped and the lineless expression can find the correct line in tokens.

Problem

Conversion of some Elixir functions to the Erlang functions that take the result as second arg instead of the first one.
For example, the elem(result, pos) function is converted to the Erlang element(pos, result).

It is solved by detecting when the call is to function from the:erlang module and if it is, the first and second args are swapped. After specifying lines the correct args order is restored.

New testing format for specifying expressions

This PR proposed a new testing format for specifying expressions similar to the one for the type pretty-printer. Test cases can be defined in the Gradient.AstData module. Each case contains the input values and the expected result. Thanks to this the expression specification can be tested without adding a new .ex file and compiling it.

I am still thinking about how to make it more pretty and flexible.

@Premwoik Premwoik force-pushed the support-loc-specifying-in-pipe-op branch 2 times, most recently from 3a913c3 to 90d26e6 Compare April 1, 2022 21:56
@erszcz
Copy link
Contributor

erszcz commented Apr 27, 2022

@Premwoik This one is still marked as a draft. Is it ready to review/merge?

@Premwoik
Copy link
Collaborator Author

@Premwoik This one is still marked as a draft. Is it ready to review/merge?

You can take a look if you have time :) I kept this one as a draft because I was not sure if it won't break something.

@Premwoik Premwoik marked this pull request as ready for review April 27, 2022 11:04
@Premwoik Premwoik requested a review from erszcz April 27, 2022 11:04
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.

🥳

@Premwoik Premwoik force-pushed the support-loc-specifying-in-pipe-op branch from a96c553 to b2b3a00 Compare May 25, 2022 09:42
Co-authored-by: João Thallis <joaothallis@icloud.com>
@Premwoik Premwoik merged commit 6ef5801 into main May 25, 2022
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.

Elixir->Erlang AST: expand pipe operator support to pass subexpression line and column info

4 participants