This is a non-blocking, stream-based parser library. The original use case was parsing incoming HTTP messages for a non-blocking server, but it might be a benefit anywhere you need to
- read data from untrusted sources (where you therefore can't assume the availability of the entire message)
- in some non-trivially parseable format
- and/or some part of the incoming message will determine how the rest of it should be treated
CL-USER> (ql:quickload :cl-lazy-parse)
To load "cl-lazy-parse":
Load 1 ASDF system:
cl-lazy-parse
; Loading "cl-lazy-parse"
[package cl-lazy-parse]...
(:CL-LAZY-PARSE)
CL-USER> (in-package :cl-lazy-parse)
#<PACKAGE "CL-LAZY-PARSE">
CL-LAZY-PARSE> (run! "testing" "test")
(#\t #\e #\s #\t)
4
CL-LAZY-PARSE> (run! "testing" "nope")
#:FAIL1129
CL-LAZY-PARSE> (run! "testing" (and>> (char>> #\t) (many>> (not-char>> #\t))))
(#\t (#\e #\s))
3
CL-LAZY-PARSE>
and>>
or>>
many>>
char>>
not-char>>
with
_fn
failed?
- Define
run-many!
, which should run the given parser as many times as possible, resetting the input buffer each time- Maybe multiples? I could see you wanting to do different things on a
failed?
result. For instance, you may want to skip to some character, close the stream, or try to run some alternate parser- To be fair, that last one is exactly what
or>>
is for
- To be fair, that last one is exactly what
- Maybe multiples? I could see you wanting to do different things on a
- Make the invocation of
run!
on astring
more efficient (it should just start with said string as the initial buffer contents; no stream stuff involved). - Document exported functions
- Document some non-trivial use cases