[erlang-questions] prettypr

Anthony Ramine n.oxyde@REDACTED
Sun May 13 20:14:30 CEST 2012


If Code is a list of forms, split its result at each '.' and call parse_form on that.

--
Anthony Ramine




Le 13 mai 2012 à 20:03, Roberto Ostinelli a écrit :

> 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.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list