<p dir="ltr">Forgot to say that sometimes I use the below example from beam_lib documentation to beautify the code, and add comments after.</p>
<p dir="ltr">{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]). io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).<br></p>
<p dir="ltr">"Envoyé depuis mon mobile " Eric</p>
<br><br>---- Éric Pailleau a écrit ----<br><br><p dir="ltr">Hi,<br>
I see an interest in keeping all source code in abstract code at least as a compilation option. <br>
This could allow to beautify code automatically with the rules of owner by rewriting back to disk the source code. <br>
Numbers of blanks per tabulation, max width of code, some want 80 colons, some other 100 for example. <br>
This could help to create a tool to let respect the coding standard of owner project. <br>
Regards <br></p>
<p dir="ltr">"Envoyé depuis mon mobile " Eric</p>
<br><br>---- Richard A. O'Keefe a écrit ----<br><br>Concerning the abstract syntax tree and recording absolutely<br>everything about the source code in it; is this really<br>necessary?<br><br>What SWI Prolog does to support its debugger is<br>- retain the source text in a file<br>- in the AST, record the beginning and length of each term.<br>For Erlang, 16#fc would be tokenised as<br> {integer,{location,Line,Col,Start,Length},252}<br><br>For a Prolog dialect converter I wrote, I adopted the rule<br>that % comments with a preceding token on the same line were<br>attached to the *preceding* term while % comments without<br>such a token were attached to the *following* term, with<br>%comments preceding a predicate attached to the following<br>predicate as a whole. Thus<br><br> % following predicate<br> foo(...) :- % foo(...)<br> % bar(...)<br> bar(...), % also bar(...).<br> ugh(...). % ugh(...)<br><br>This seemed to fit user expectations pretty well.<br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>