mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
|%
|
|
::
|
|
:: A `plum` is the intermediate representation for the pretty-printer. It
|
|
:: encodes hoon-shaped data with the least amount of structured needed
|
|
:: for formating.
|
|
::
|
|
:: A `plum` is either a
|
|
::
|
|
:: - `cord`: A simple cord
|
|
:: - `[%para *]`: A wrappable paragraph.
|
|
:: - `[%tree *]`: A formated plum tree
|
|
:: - `[%sbrk *]`: An indication of a nested subexpression.
|
|
::
|
|
:: The formatter will use the tall mode unless:
|
|
::
|
|
:: - A plum has only a `wide` style.
|
|
:: - The plum is in `%sbrk` form and it's subplum (`kid`), when
|
|
:: formatted in wide mode, can fit on a single line.
|
|
::
|
|
+$ plum
|
|
$@ cord
|
|
$% [%para prefix=tile lines=(list @t)]
|
|
[%tree fmt=plumfmt kids=(list plum)]
|
|
[%sbrk kid=plum]
|
|
==
|
|
::
|
|
:: A `plumfmt` is a description of how to render a `plum`. A `plumfmt`
|
|
:: must include a `wide`, a `tall`, or both.
|
|
::
|
|
:: A `wide` is a description of how to render a plum in a single
|
|
:: line. The nested (`kids`) sub-plums will be interleaved with `delimit`
|
|
:: strings, and, if `enclose` is set, then the output will be enclosed
|
|
:: with `p.u.enclose` abnd `q.u.enclose`.
|
|
::
|
|
:: For examle, to build a plumfmt for string literals, we could write:
|
|
::
|
|
:: [wide=[~ '' [~ '"' '"']] tall=~]
|
|
::
|
|
:: A `tall` is a description of how to render a plum accross multiple
|
|
:: lines. The output will be prefixed by `intro`, suffixed by
|
|
:: `final.u.indef`, and each subplum prefixed by `sigil.u.indef`.
|
|
::
|
|
:: For example, to build a plumfmt for cores, we could write:
|
|
::
|
|
:: [wide=~ tall=`['' `['++' '--']]]
|
|
::
|
|
+$ plumfmt
|
|
$: wide=(unit [delimit=tile enclose=(unit (pair tile tile))])
|
|
tall=(unit [intro=tile indef=(unit [sigil=tile final=tile])])
|
|
==
|
|
--
|