Subject: Re: scanning a string?
From: (Rob Warnock)
Date: 2000/09/18
Newsgroups: comp.lang.lisp
Message-ID: <8q4ihc$tskjg$>
Konst Sushenko <> 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".]


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
Network Engineering
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043