Regexp Alternatives (was Re: Wondering what I'm doing wrong?)
"Adam Weaver (as adam at cleversure dot com dot au)" <[email protected]> Fri, 12 Jun 2026 00:45:42 +0000
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
> On 12/6/26 08:18, David McClain (as dbm at refined-audiometrics dot
com) wrote:
> CL-PPCRE
> ;; About 84s for 10^5 iters, so 840μs/iter
> ;; Allocation = 38,992,235,512 bytes, or 389,922 bytes/iter
> ;; 2292 Page faults
>
> ESRAP (PEG Packrat?)
> ;; About 68s for 10^5 iters, so 680μs/iter
> ;; Allocation = 34,755,853,968 bytes, or 347,558 bytes/iter
> ;; 5181 Page faults
>
> Parseq (PEG Non-Packrat)
> ;; About 19s for 10^5 iters, so 190μs/iter
> ;; Allocation = 9,121,975,192 bytes, or 91,219 bytes/iter
> ;; 209 Page faults
That is rather interesting! Never occurred to me to use anything other
than regexps
for stringy work.
Hmm.. I wonder how PARSERGEN:DEFPARSER fares?
I tend to use PARSERGEN:DEFPARSER for as much as I can, e.g. a JSON parser:
(parsergen:defparser json-dom-parser
((<toplevel> <element>))
(<array-element*>
((<element> #\, <array-element*>) (cons $1 $3))
((<element>) (cons $1 nil)))
(<object-element*>
((:string #\: <element> #\, <object-element*>) (list* $1 $3 $5))
((:string #\: <element>) (list $1 $3)))
(<element>
((:number) $1)
((:string) $1)
((:null) nil)
((t) $1)
((#\[ <array-element*> #\]) (coerce $2 'vector))
((#\[ #\]) (vector))
((#\{ <object-element*> #\}) (loop with hash = (make-hash-table
:test #'equalp)
for (key value) on $2 by #'cddr
do (setf (gethash key hash) value)
finally (return hash)))
((#\{ #\}) (make-hash-table :test #'equalp))))
DM, I don't suppose you're interested in trying your number parser out
using LW's built-in PARSERGEN package?
A.
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html