<div class="gmail_quote">On Fri, May 11, 2012 at 6:33 PM, Andrew Berman <span dir="ltr"><<a href="mailto:rexxe98@gmail.com" target="_blank">rexxe98@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What about this?<br><br>Comments = erl_comment_scan:string(Text),<br>{ok, Form, _} = erl_scan:string(Text),<br>{ok, Tree} = erl_parse:parse_form(Form), <br>{Tree2, _} = erl_recomment:recomment_tree(Tree, Comments),<div>erl_prettypr:format(Tree2).<span class="HOEnZb"><font color="#888888"><div>
</div></font></span></div></blockquote><div><br></div><div>hello andrew,</div><div><br></div><div>this looks interesting, though i cannot find a way to parse a whole mudule:</div><div><br></div><div><br></div><div>%%%%%%%%%%%%%%%%%%%%%%%%%%</div>
<div><div>-module(pretty).</div><div>-compile(export_all).</div><div><br></div><div>start() -></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>Code = "-module(start).</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>-export([start/0]).</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>start() ->ok.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>% a comment here.",</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>Comments = erl_comment_scan:string(Code),</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>{ok, Form, _} = erl_scan:string(Code),</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>{ok, Tree} = erl_parse:parse_form(Form), </div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>{Tree2, _} = erl_recomment:recomment_tree(Tree, Comments),</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>erl_prettypr:format(Tree2).</div>
</div><div>%%%%%%%%%%%%%%%%%%%%%%%%%%</div><div><br></div><div><br></div><div><div>1> pretty:start().</div><div>** exception error: no match of right hand side value {error,{2,erl_parse,["syntax error before: ","'-'"]}}</div>
<div>     in function  pretty:start/0 (pretty.erl, line 13)</div></div><div><br></div><div>any ideas?</div><div><br></div><div>r.</div></div>