Subject: Re: Parsing/Lexing in Scheme
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1998/02/11
Newsgroups: comp.lang.scheme
Message-ID: <6brhq5$487k@fido.asd.sgi.com>

Pierre Mai  <dent@cs.tu-berlin.de> wrote:
+---------------
| Has someone built an implementation of Common Lisp read (i.e. with
| read-tables and things like read-delimited-list, etc.) in Scheme...
+---------------

You might want to look at "SIOD" <URL:http://people.delphi.com/gjc/siod.html>
which says this in the man page:

   ALTERNATIVE SYNTAX
     Files which are loaded by the interpreter  may  contain  the
     sequence  of  characters  parser:XXXXX  in  a comment in the
     first line[*] of the file.  This will result in  the  automatic
     loading  of  the  file parser_XXXXX.scm which must provide a
     procedure parser_XXXXX to return a  procedure  to  read  the
     forms  from  the  file  to be loaded. Useful values of XXXXX
     include read, pratt, and fasl.

[* actually, first few comment lines of a file], which allows things
like this:

	#!/usr/local/bin/siod -v01,-m2 
	#-*-mode:text;parser:pratt-*-

	main() := 
	{writes(nil,"Hello Scheme World.\n");
	 fflush(nil);
	 writes(nil,"fib(20) = ",fib(20),"\n");
	}
	$

	fib(x) := if x < 2 then x else fib(x-1) + fib(x-2)
	$

Alternatively, MzScheme has "custom ports" and SCM has "soft ports",
which let you put Scheme procedures behind a port, so you could write
a wrapper around a plain file port.


-Rob

-----
Rob Warnock, 7L-551		rpw3@sgi.com   http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673 [New area code!]
2011 N. Shoreline Blvd.		FAX: 650-933-4392
Mountain View, CA  94043	PP-ASEL-IA