1
1
mirror of https://github.com/urbit/shrub.git synced 2024-12-25 04:52:06 +03:00
shrub/pkg/arvo/sur/plum.hoon
Joe Bryan d6e5b19b3d Merge branch 'na-release/candidate' into jb/no-wrap-tank
* na-release/candidate: (31 commits)
  pill: change to ropsten
  zuse: change to ropsten
  pill: all
  u3: fix accidental neologism in comments
  pill: solid
  u3: refactors dynamic hint bytecodes, documents protocol
  u3: adds dynamic hint bytecodes and implementation
  u3: moves _n_swap() next to other stack ops
  u3: adds ghetto +mook replacement
  u3: moves |ut battery to the rightmost cache key position
  u3: adds |ut battery to jet cache keys
  pill: solid
  pill: solid.pill
  hoon: bscl to bccl, etc
  pill: solid
  hoon: modernizes syntax in the rest of |co
  hoon: updates @p rendering to avoid intermediate right-shifts
  hoon: refactors @da/@dr coin printing
  hoon: comments, modernizes syntax for all +*-co:co gates
  hoon: refactors +r-co:co, modernizing syntax
  ...
2020-11-23 23:15:12 -08:00

56 lines
1.7 KiB
Plaintext

^? |%
::
+$ tile :: XX: ?@(knot (pair styl knot))
::
cord
::
:: 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 formatted 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 its 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` and `q.u.enclose`.
::
:: For example, to build a plumfmt for string literals, we could write:
::
:: [wide=[~ '' [~ '"' '"']] tall=~]
::
:: A `tall` is a description of how to render a plum across 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])])
==
--