Replacing els_dodger with a different parser #865
Replies: 3 comments 4 replies
-
You have to convince WhatsApp folks to extract that parser to its own lib... Like katana-code. Maybe erlcode... |
Beta Was this translation helpful? Give feedback.
-
While working on the feature to rename functions I've come to realize that the current parser is not sufficient. Some examples that I've thought about where calculation of the end location will be wrong: %% Numbers separated with underscore
100_000_000
%% quoted atoms
'foo'
%% Additional whitespace
fun foo/1 I think it could be interesting to try to plug in the erlfmt parser as an experiment. |
Beta Was this translation helpful? Give feedback.
-
I took a few stabs at using erlfmt in els_parser and the results look promising. This adapter by Richard Carlsson into erl_syntax trees definitely saved a lot of time WhatsApp/erlfmt#237 First I tried how much erlfmt_ast can be a drop in replacement for els_dodger, keeping the reverse-engineering, but there are a few differences still, mostly related to start locations. (I patched erlfmt_ast to handle types the same way as our els_dodger is patched) On the version which also takes end_location from erlfmt I'm close to fixing all the diffs and test cases. Listing the diffs for the record if anyone would like to try the replacement in other tools:
|
Beta Was this translation helpful? Give feedback.
-
Recently I've been more and more tempted to look at the parser of erlfmt as a replacement for the current epp_dodger-based one. erlfmt_parser has the following advantages:
I wanted to be able to parse the following code and have a POI for
?InnerMacro
Input
in the below example (today the function can't be parsed and results in no POIs)Most of this could be probably addressed by further work in els_parser and hacking els_dodger further, but then will have to diverge from epp_dodger and feels duplicate work.
Disadvantages:
What do you all think?
Beta Was this translation helpful? Give feedback.
All reactions