Subject: Re: scanning a string?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/09/18
Newsgroups: comp.lang.lisp
Message-ID: <8q4ihc$tskjg$1@fido.engr.sgi.com>
Konst Sushenko <konsu@worldnet.att.net> wrote:
+---------------
| but if i convert my regexp string into a list before processing it, then i
| would have to return multiple values from my sub-functions: the result and
| the remaining input list...
+---------------

There's no nead to avoid multiple values -- Common Lisp has them
conveniently built into the language. In fact, when writing tiny
parsers of various kinds, I often do exactly as you suggest: Call
a routine to parse some construct, and have it return the parsed
phrase/object/structure/whatever and the list of unused characters:

	(multiple-value-bind (result-thing remaining-chars)
	    (parse-a-thing some-chars)
	  ;; do something with the parsed "result-thing",
	  ;; handing the "remaining-chars" to the next parser
	  ... )

[Also see "multiple-value-setq".]


-Rob

p.s. But before taking me literally and heading off to code a regexp in
that form, first look in your Lisp implementation's documentation -- you
may find there's a perfectly usable regexp library there already!

-----
Rob Warnock, 41L-955		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043