6# 3g: molds and mold builders
9Noun literal syntax cases
11Noun literal syntax cases: atoms, jammed nouns, and nestable tuples.
12Parsed and printed using `++so` and `++co` cores.
17 ++ coin $% {$$ p/dime} ::
19 {$many p/(list coin)} ::
25 > `coin`(need (slay '~s1'))
26 [%$ p=[p=~.dr q=18.446.744.073.709.551.616]]
27 > `coin`(need (slay '0x2b59'))
28 [%$ p=[p=~.ux q=11.097]]
30 > ~(rend co [%many ~[[%$ %ud 1] [%$ %tas 'a'] [%$ %s -2]]])
49Used in `++coin`. Convenience methods `++scot` and `++scow` (in
50Section 2eL) print dimes as `++cord` and `++tape`, respectively.
51`++slat`, `++slav`, and `++slaw` are used to parse atoms of
57 ++ dime {p/@ta q/@} ::
71Parsing location metadata
73Optional result `p` and parsing continuation `q`.
78 ++ hair {p/@ud q/@ud} :: parsing trace
84See also: Section 2eD, `++rule`
88 > (tall:vast [1 1] "a b")
89 [p=[p=1 q=2] q=[~ [p=[%cnzz p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]]
96Parsing line and column
98A pair of two [`@ud`]() used in parsing indicating line and column number.
103 ++ hair {p/@ud q/@ud} :: parsing trace
112 > `hair`[1 1] :: parsing starts at [1 1] as a convention.
114 > ((plus ace) [1 1] " --")
115 [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]]
116 > `hair`p:((plus ace) [1 1] " --")
124Mold generator for an edge
126`++like` generates an `++edge` with a parsed result set to a specific type.
131 ++ like |* a/$-(* *) :: generic edge
132 |= b/_`*`[(hair) ~] ::
137 u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] ::
146 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
147 > `(like char)`(ace [1 1] " a")
148 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
149 > `(like ,@)`(ace [1 1] " a")
150 [p=[p=1 q=2] q=[~ [p=32 q=[p=[p=1 q=2] q="a"]]]]
157Location, remainder of parsed text
159Indicates parsing position `p`, and remaining text to be parsed `q`.
164 ++ nail {p/hair q/tape} :: parsing input
170 > +<:;~(plug cab cab)
171 c=tub=[p=[p=0 q=0] q=""]
181A `++path` is a list of `++span`s aka `@ta`. Used in
182`%clay` and `%eyre` extensively.
187 ++ path (list knot) :: filesys location
203Mostly used for stacktraces. A `++pint` is a pair of
204`++hair`, indicating from `p` to `q`.
209 ++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range
216 ! /~zod/try/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]>
217 > :: !! always produces a crash
218 > `pint`[[1 4] [1 6]]
219 [p=[p=1 q=4] q=[p=1 q=6]]
228`++rule` is an empty parsing rule, but it is used to check
229that parsing rules match this with `_`.
235 ++ rule _|=(nail *edge) :: parsing rule
242 [p=[p=0 q=0] q=[~ [p=0 q=[p=[p=0 q=0] q=""]]]]
244 > ^+(rule [|=(a=nail [p.a ~])]:|6)
245 <1.dww [tub=[p=[p=@ud q=@ud] q=""] <101.jzo 1.ypj %164>]>
246 > (^+(rule [|=(a=nail [p.a ~ u=['a' a]])]:|6) [1 1] "hi")
247 [p=[p=1 q=1] q=[~ [p=97 q=[p=[p=1 q=1] q="hi"]]]]
248 > ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi")
249 [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]]
258A `++spot` is what we print after crashing.
263 ++ spot {p/path q/pint} :: range in file
269 > :into /=main=/bin/fail/hoon '!: !!'
270 + /~zod/main/359/bin/fail/hoon
272 ! /~zod/main/~2014.9.22..18.40.56..ef04/bin/fail/:<[1 5].[1 7]>
280Nock computation result
282Either success (`%0`), a block with list of requests blocked on (`%1`), or
283failure with stack trace (`%2`).
288 ++ toon $% {$0 p/*} :: success
289 {$1 p/(list)} :: blocks
290 {$2 p/(list tank)} :: stack trace
296 > (mock [[20 21] 0 3] $~)
298 > (mock [[0] !=(.^(cy//=main/1))] ,~)
299 [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]]
300 > (path [31.075 1.685.027.454 1.852.399.981 49 0])
303 > (mock [[1 2] !=(!:(+(.)))] ,~)
304 [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]]
313Pull result out of a `++edge`, or crash if there's no result.
318 ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) ::
323See also: [`++edge`]()
325 > (wide:vast [1 1] "(add 2 2)")
329 [ p=[%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]]
330 q=[p=[p=1 q=10] q=""]
334 > (wonk (wide:vast [1 1] "(add 2 2)"))
335 [%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list