on bfaa358 help sign in
43 lines 961 B history raw
1### `++scan`
3Parse tape or crash
5Parse a `++tape` with a given `++rule` and crash if the `++tape` isn't entirely
6parsed.
8Accepts
9-------
11`los` is a tape.
13`sab` is a rule.
15Produces
16--------
18Either a `++tape` or a crash.
20Source
21------
23 ++ scan |* {los/tape sab/rule}
24 =+ vex=((full sab) [[1 1] los])
25 ?~ q.vex
26 ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~)
27 ~|('syntax-error' !!)
28 p.u.q.vex
30Examples
31--------
33 ~zod/try=> (scan "I was the world in which I walked, and what I saw" (star (shim 0 200)))
34 "I was the world in which I walked, and what I saw"
35 ~zod/try=> (scan "Or heard or felt came not but from myself;" (star (shim 0 200)))
36 "Or heard or felt came not but from myself;"
37 ~zod/try=> (scan "And there I found myself more truly and more strange." (jest 'And there I'))
38 ! {1 12}
39 ! 'syntax-error'
40 ! exit
43***