++rash
Parse or crash
Parse a cord with a given rule
and crash if the cord
isn't entirely parsed.
Accepts
naf
is an atom.
sab
is a rule
.
Produces
The value of the parse result, or crash.
Source
++ rash |*([naf=@ sab=rule] (scan (trip naf) sab))
Examples
> (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"> (rash 'abc' (just 'a'))! {1 2}! 'syntax-error'! exit> (rash 'abc' (jest 'abc'))'abc'> (rash 'abc' (jest 'ab'))! {1 3}! 'syntax-error'! exit
++rose
Parse to each
Parse tape
los
with rule
sab
, producing an (each @ud (unit *))
. If los
was not fully consumed, the result is %.n
and p
contains the column number before failure occurred. If los
was fully consumed, the result is %.y
and p
contains either sab
's result in a unit
, or a null unit
if parsing failed.
Accepts
los
is a tape
.
sab
is a rule
.
Produces
(each @ud (unit *))
, where the *
is whatever type the rule
produces.
Source
++ rose |* [los=tape sab=rule]=+ vex=(sab [[1 1] los])=+ len=(lent los)?. =(+(len) q.p.vex) [%| p=(dec q.p.vex)]?~ q.vex[%& p=~][%& p=[~ u=p.u.q.vex]]
Examples
> (rose "!" zap)[%.y p=[~ u='!']]> (rose "?" zap)[%.n p=0]> (rose "!?" zap)[%.n p=1]> (rose "!" ;~(plug zap fail))[%.y p=~]
++rush
Parse or null
Parse an atom with a given rule and produce null if the cord isn't entirely parsed.
Accepts
naf
is an atom.
sab
is a rule.
Produces
The value of the parse result, or null.
Source
++ rush |*([naf=@ sab=rule] (rust (trip naf) sab))
Examples
> (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"]> (rush 'abc' (just 'a'))~> (rush 'abc' (jest 'abc'))[~ 'abc']> (rush 'abc' (jest 'ac'))~> (rush 'abc' (jest 'ab'))~
++rust
Parse tape or null
Parse a tape
with a given rule
and produce null if the tape
isn't entirely parsed.
Accepts
los
is a tape
.
sab
is a rule
.
Produces
A (unit *)
, where *
is the type produced by sab
.
Source
++ rust |* [los=tape sab=rule]=+ vex=((full sab) [[1 1] los])?~(q.vex ~ [~ u=p.u.q.vex])
Examples
> (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"]> (rust "Or heard or felt came not but from myself;" (star (shim 0 200)))[~ "Or heard or felt came not but from myself;"]> (rust "And there I found myself more truly and more strange." (jest 'And there I'))~
++scan
Parse tape or crash
Parse a tape
with a given rule
and crash if the tape
isn't entirely parsed.
Accepts
los
is a tape
.
sab
is a rule
.
Produces
Either a tape
or a crash.
Source
++ scan |* [los=tape sab=rule] =+ vex=((full sab) [[1 1] los]) ?~ q.vex ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~) ~_(leaf+"syntax error" !!) p.u.q.vex
Examples
> (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"> (scan "Or heard or felt came not but from myself;" (star (shim 0 200)))"Or heard or felt came not but from myself;"> (scan "And there I found myself more truly and more strange." (jest 'And there I'))! {1 12}! 'syntax-error'! exit