mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-19 12:51:51 +03:00
6cbb6b060d
This reverts commit 8e1e40d75b3ab15c194b6bf9570f3edc46e2de58. This reverts commit f073c490f9fd7c5abc033af4857df92229877de7. This reverts commit f187d2d7e01a54823f3e979af9bbd148b398e7e9. This reverts commit bc272862a73cfce1b118586ca39d3a377d841f1b. This reverts commit 30a397513f8890a3406dc7ab91c6e067e3bbfbbb. This reverts commit 4fc6856fb50d88c20a0f533392ca606641c5f38f. Conflicts: urb/urbit.pill urb/zod/base/lib/drum.hoon
3.1 KiB
3.1 KiB
section 2eI, parsing (external)
++rash
Parse or crash
++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) ::
Parse a cord with a given rule and crash if the cord isn't entirely parsed.
naf
is an atom.
sab
is a rule.
~zod/try=> (rash 'I was the world in which I walked, and what I saw' (star (shim 0 200)))
"I was the world in which I walked, and what I saw"
~zod/try=> (rash 'abc' (just 'a'))
! {1 2}
! 'syntax-error'
! exit
~zod/try=> (rash 'abc' (jest 'abc'))
'abc'
`~zod/try=> (rash 'abc' (jest 'ab'))
! {1 3}
! 'syntax-error'
! exit
++rush
Parse or null
++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab))
Parse a given with a given rule and produce null if the cord isn't entirely parsed.
naf
is an atom.
sab
is a rule.
~zod/try=> (rush 'I was the world in which I walked, and what I saw' (star (shim 0 200)))
[~ "I was the world in which I walked, and what I saw"]
~zod/try=> (rush 'abc' (just 'a'))
~
~zod/try=> (rush 'abc' (jest 'abc'))
[~ 'abc']
~zod/try=> (rush 'abc' (jest 'ac'))
~
~zod/try=> (rush 'abc' (jest 'ab'))
~
++rust
Parse tape or null
++ rust |* [los=tape sab=_rule]
=+ vex=((full sab) [[1 1] los])
?~(q.vex ~ [~ u=p.u.q.vex])
Parse a tape with a given rule and produce null if the tape isn't entirely parsed.
los
is a tape.
sab
is a rule.
~zod/try=> (rust "I was the world in which I walked, and what I saw" (star (shim 0 200)))
[~ "I was the world in which I walked, and what I saw"]
~zod/try=> (rust "Or heard or felt came not but from myself;" (star (shim 0 200)))
[~ "Or heard or felt came not but from myself;"]
~zod/try=> (rust "And there I found myself more truly and more strange." (jest 'And there I'))
~
++scan
Parse tape or crash
++ scan |* [los=tape sab=_rule]
=+ vex=((full sab) [[1 1] los])
?~ q.vex
~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~)
~|('syntax-error' !!)
p.u.q.vex
Parse a tape with a given rule and crash if the tape isn't entirely parsed.
los
is a tape.
sab
is a rule.
~zod/try=> (scan "I was the world in which I walked, and what I saw" (star (shim 0 200)))
"I was the world in which I walked, and what I saw"
~zod/try=> (scan "Or heard or felt came not but from myself;" (star (shim 0 200)))
"Or heard or felt came not but from myself;"
~zod/try=> (scan "And there I found myself more truly and more strange." (jest 'And there I'))
! {1 12}
! 'syntax-error'
! exit