<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Here is how it's done in parse_trans_pp.erl (<a href="http://github.com/uwiger/parse_trans">http://github.com/uwiger/parse_trans</a>)</div><div><br></div><div><div>pp_beam_to_str(F) -></div><div> case beam_lib:chunks(F, [abstract_code]) of</div><div> {ok, {_, [{abstract_code,{_,AC0}}]}} -></div><div> AC = epp:restore_typed_record_fields(AC0),</div><div> {ok, lists:flatten(</div><div> io_lib:fwrite("~s~n", [lists:flatten(</div><div> [erl_pp:form(Form) ||</div><div> Form <- AC])])</div><div> )};</div><div> Other -></div><div> {error, Other}</div><div> end.</div></div><div><br></div><div>BR,</div><div>Ulf W</div><div><br></div><br><div><div>On 1 Mar 2012, at 22:17, Stavros Aronis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Jason,<div><br></div><div>The lack of support for types in erl_syntax is something that has bothered me as well and I think that I ran into the same issue with the erlang parser when I was trying to do some work there. If this is indeed the case, there should definitely be a way to make the representation of types in the abstract syntax better and uniform (for the records case).</div><div><br></div><div>Keep in mind however that at least two tools (Dialyzer and EDoc) have been designed to use the current representation, so any change will need to be compatible with those. I can definitely help with the Dialyzer front.</div><div><br></div><div>Regards,</div><div>Stavros</div><div><br>On Thursday, March 1, 2012 3:06:24 PM UTC+1, Jason Rogers wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I've noticed a lack of support for types and specs in erl_syntax or<br>erl_prettypr.<p>If you try:</p><p>{ok,{_,[{abstract_code,{_,AC}}<wbr>]}} = beam_lib:chunks(Beam,[<wbr>abstract_code]).<br>io:fwrite("~s~n", [erl_prettypr:format(erl_<wbr>syntax:form_list(AC))]).</p><p>on a beam file with type or spec declarations, the resulting code will<br>not compile.</p><p>Any idea if official support is forthcoming?</p><p>I tried to modify both libraries to provide some minimal support for<br>my own use, but ran into an issue with typed records. A typed record<br>shows up in the syntax tree twice: as a un-typed record and as a typed<br>record. And the typed version, which includes all the information<br>contained in the un-typed declaration, appears after the un-typed<br>declaration.</p><p>So if you write code to process the typed version, you will end up<br>with source code that has both a typed and an un-typed declaration.</p><p>Is there anyway to get to a single record declaration?</p><p>Thanks,<br>Jason<br>______________________________<wbr>_________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br></p><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div></blockquote></div><br>On Thursday, March 1, 2012 3:06:24 PM UTC+1, Jason Rogers wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I've noticed a lack of support for types and specs in erl_syntax or<br>erl_prettypr.<p>If you try:</p><p>{ok,{_,[{abstract_code,{_,AC}}<wbr>]}} = beam_lib:chunks(Beam,[<wbr>abstract_code]).<br>io:fwrite("~s~n", [erl_prettypr:format(erl_<wbr>syntax:form_list(AC))]).</p><p>on a beam file with type or spec declarations, the resulting code will<br>not compile.</p><p>Any idea if official support is forthcoming?</p><p>I tried to modify both libraries to provide some minimal support for<br>my own use, but ran into an issue with typed records. A typed record<br>shows up in the syntax tree twice: as a un-typed record and as a typed<br>record. And the typed version, which includes all the information<br>contained in the un-typed declaration, appears after the un-typed<br>declaration.</p><p>So if you write code to process the typed version, you will end up<br>with source code that has both a typed and an un-typed declaration.</p><p>Is there anyway to get to a single record declaration?</p><p>Thanks,<br>Jason<br>______________________________<wbr>_________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br></p><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div></blockquote>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br></body></html>