Erlang shell print depth and print length: how to change?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Erlang shell print depth and print length: how to change?

Arthur Reyes
Dear Erlang Friend:

I need to inspect Erlang abstract syntax trees (ASTs) produced by
epp:parse_file/3 and similar functions.

When given the filename and path of a large Erlang source code file,
epp:parse_file/3 returns a long list of deeply nested tuples.

The returned list is often so long the Erlang shell elides the end of
it with ellipses (...). The tuples are often so deeply nested the
Erlang shell elides the deeper components with ellipses as well.

If you know, please provide me a reference to modules and functions
that allow the user of the Erlang shell to modify the shell's print
depth and print length.

Thank you.

--
Arthur Alexander Reyes, Assistant Professor   VOICE: (817) 272-7408
Dept. Computer Science & Engineering            FAX: (817) 272-3784
University of Texas at Arlington     http://www-cse.uta.edu/~reyes/
Box 19015, Arlington, TX 76019-0015               reyes


Reply | Threaded
Open this post in threaded view
|

Erlang shell print depth and print length: how to change?

Richard Carlsson-4

On Mon, 5 Feb 2001, Arthur Reyes wrote:

> Dear Erlang Friend:
>
> I need to inspect Erlang abstract syntax trees (ASTs) produced by
> epp:parse_file/3 and similar functions.
>
> When given the filename and path of a large Erlang source code file,
> epp:parse_file/3 returns a long list of deeply nested tuples.
>
> The returned list is often so long the Erlang shell elides the end of
> it with ellipses (...). The tuples are often so deeply nested the
> Erlang shell elides the deeper components with ellipses as well.

I would not go as far as to suggest that you try to modify the behaviour
of the shell itself, but this would show you the whole structure:

        io:fwrite("~p", [epp:parse_file("foo.erl", [], [])])

If you want to analyse the syntax tree in more detail, I recommend my
"syntax tools" package, which works as an abstract layer hiding the actual
representation details. It also comes with a more advanced pretty-printer
than the standard library 'erl_pp'.

        http://www.erlang.org/user.html#syntax_tools-1.0


    /Richard Carlsson


Richard Carlsson (richardc)   (This space intentionally left blank.)
E-mail: Richard.Carlsson WWW: http://www.csd.uu.se/~richardc/




Reply | Threaded
Open this post in threaded view
|

Erlang shell print depth and print length: how to change?

Ulf Wiger-4
In reply to this post by Arthur Reyes
On Mon, 5 Feb 2001, Arthur Reyes wrote:

>Dear Erlang Friend:
>
>I need to inspect Erlang abstract syntax trees (ASTs) produced by
>epp:parse_file/3 and similar functions.
>
>When given the filename and path of a large Erlang source code file,
>epp:parse_file/3 returns a long list of deeply nested tuples.
>
>The returned list is often so long the Erlang shell elides the end
>of it with ellipses (...). The tuples are often so deeply nested the
>Erlang shell elides the deeper components with ellipses as well.
>
>If you know, please provide me a reference to modules and functions
>that allow the user of the Erlang shell to modify the shell's print
>depth and print length.


What I usually do is this:



{ok, Fd} = file:open("tempfile.txt", [write]),
io:fwrite(Fd, "~p~n", [epp:parse_file(...)]),
file:close(Fd).


Then, I inspect the result using less or Emacs.


/Uffe
--
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB