[erlang-questions] Erlang documentation -- a modest proposal

Richard A. O'Keefe <>
Wed Sep 28 01:14:37 CEST 2016

Concerning the abstract syntax tree and recording absolutely
everything about the source code in it; is this really

What SWI Prolog does to support its debugger is
- retain the source text in a file
- in the AST, record the beginning and length of each term.
For Erlang, 16#fc would be tokenised as

For a Prolog dialect converter I wrote, I adopted the rule
that % comments with a preceding token on the same line were
attached to the *preceding* term while % comments without
such a token were attached to the *following* term, with
%comments preceding a predicate attached to the following
predicate as a whole.  Thus

    % following predicate
    foo(...) :- % foo(...)
       % bar(...)
       bar(...), % also bar(...).
       ugh(...). % ugh(...)

This seemed to fit user expectations pretty well.

More information about the erlang-questions mailing list