[erlang-questions] prettypr

Roberto Ostinelli roberto@REDACTED
Sun May 13 20:03:36 CEST 2012


On Fri, May 11, 2012 at 6:33 PM, Andrew Berman <rexxe98@REDACTED> wrote:

> What about this?
>
> Comments = erl_comment_scan:string(Text),
> {ok, Form, _} = erl_scan:string(Text),
> {ok, Tree} = erl_parse:parse_form(Form),
> {Tree2, _} = erl_recomment:recomment_tree(Tree, Comments),
> erl_prettypr:format(Tree2).
>

hello andrew,

this looks interesting, though i cannot find a way to parse a whole mudule:


%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(pretty).
-compile(export_all).

start() ->
Code = "-module(start).
-export([start/0]).

start() ->ok.

% a comment here.",
Comments = erl_comment_scan:string(Code),
{ok, Form, _} = erl_scan:string(Code),
{ok, Tree} = erl_parse:parse_form(Form),
{Tree2, _} = erl_recomment:recomment_tree(Tree, Comments),
erl_prettypr:format(Tree2).
%%%%%%%%%%%%%%%%%%%%%%%%%%


1> pretty:start().
** exception error: no match of right hand side value
{error,{2,erl_parse,["syntax error before: ","'-'"]}}
     in function  pretty:start/0 (pretty.erl, line 13)

any ideas?

r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120513/cec139b5/attachment.htm>


More information about the erlang-questions mailing list