AdaCore / uwrap

1 stars 0 forks source link

Buffer col #12

Closed QuentinOchem closed 4 years ago

QuentinOchem commented 4 years ago

This patch implements a demonstrator for pretty printing (see issue #11).

The most significant change is the semantic of text. Doing A & B or "something \e" used not to create actual strings, but "by intention" string concatenations. This is useful because e.g. A and B may not be known at the time of the concatenation. However, this means that at the point of the expression, the actual text before is not known. E.g. if one write:

A & (match something pick B else pick C)

If something depends of A, as A is not known yet, the match expression may take the wrong value. This prevented from writing functions that described columns on the text being written, e.g.:

A & (match current_col pick B else pick C)

The natural way to do the above is to use a defer expression. However, with previous implementation, defer would first build the concatenation sequence, making the decision for the match above, then converting.

The presence of both defer expressions and late concatenation evaluation also introduces some confusions, when sometimes one is enough but not always.

Therefore, changing concatenation to in-line evaluation not only allows to implement column computation, it also simplifies some confusing aspects of the language.

The above changed also allowed to introduce three new instrinsics:

It also refactors the way indentation strings are computed, as the indentation now needs to be performed directly in the string evaluation algorithm, line by line, so that any expression evaluated in the string has proper line / column information.