| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In this commit, output variables in the TXR Pattern language and
in TXR Lisp quasiliterals now support separator strings for values
that are strings and buffers. Values which are buffers appear
differently: they are rendered as a sequence of lower case hex
digit pairs. When a string-valued variable specifies a separator,
the separator appears between characters of the string value.
Previously, the separator was ignored. When a buffer-valued
variable specifies a separator. the separator appears between
pairs of digits, not between digits. For instance if ethaddr
is a variable holding #b'08:00:27:79:c7:f5', then the quasiliteral
`@ethaddr` produces "08002779c7f" whereas `@{ethaddr ":"}`
produces "08:00:27:79:c7:f5".
* buf.[ch] (buf_str_sep): New function.
* lib.[ch] (fmt_str_sep): New function.
* eval.c (fmt_cat): If the argument is a string, and a separator
is present, replace the value with the result of calling
fmt_str_sep. If the argument is a buffer, and a separator is
present, use buf_str_sep to convert to a string, otherwise
use tostringp.
* txr.1: Section on Output Variables updated.
* tests/012/readprint.tl: New tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The pprint semantics of buffers is that the
raw bytes are dumped into the stream. This is poor.
It was hastily designed based on analogy with
strings, which pprint by just sending their contents
to the stream; but for strings this is justified
because they represent text.
We also fix the semantics of buffer values being
rendered by quasiliteral notation. Currently, the
are treated as sequences, and so they explode into
individual decimal integers.
* buf.c (buf_pprint): Print the bytes as pairs of
lower-case hex digits, with no line breaks.
In 294 compatibility or lower, put out bytes as before.
* eval.c (fmt_cat): When not in 294 compatibility
mode, treat a buffer object via tostringp, which
will render it to hexadecimal via buf_pprintf.
In compatibility mode, treat it as before, which is
as a sequence: the individual values of the buffer
are converted to text, thus decimal values in the
range 0 to 255, catenated using the given separator.
* tests/012/readprint.tl: New tests.
* txr.1: Documented. Also expanding on what pretty printing
means in TXR.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): In the case when dwim
has no args, and the logic short circuits to
a closing brace, bypassing the loop, we should
only use the dot notation if the terminating
atom is other than nil.
* tests/012/readprint.tl: Tests added.
|
|
* lib.c (obj_print_impl): Handle (dwim . atom) syntax
by printing [. atom]. Note that (dwim . @var)
and (dwim . @(expr)) already print as [. @var]
and [. @(expr)]; this is not new. But none of these
forms are supported by reading without the
accompanying change to the parser.
* parser.y (dwim): Handle the [. expr] and [ . expr]
syntax, so that forms like [. a] and [. @a] have
print-read consistency. The motivation is to be
able to [. @args] in pattern matching to match a
DWIM forms; I tried that and was surprised to have it
blow up in my face.
* tests/012/readprint.tl: New test file. Future
printer/parser changes will be tested here. Historically,
changes to the syntax have not been consistently
unit-tested.
* y.tab.c.shipped: Regenerated.
|