gjc@mitech.COM (02/04/91)
Archive-name: languages/scheme/siod/1991-02-02
Archive: bu.edu:/users/gjc/siod-v2.4-shar [128.197.2.6]
Original-posting-by: gjc@mitech.COM
Original-subject: Alternative scheme syntax: PRATT.SCM in Siod V2.4
Reposted-by: emv@ox.com (Edward Vielmetti)
One alternative syntax used in the days of Maclisp at MIT
was called CGOL. A parser that uses the same techniques as
CGOL is available in Siod Version 2.4
{"Advertisement" for siod follows, skip to closing bracket to
get a discussion of how to hook up alternative syntax
-----------------------------------------------------------------
What is SIOD? It is an extremely small scheme implementation in C
arranged as set of subroutines that can be called from any main
program for the purpose of introducing an interpreted extension
language.
How small is it? Compiling using the VAX/VMS C compiler results in a
total of 16333 bytes of executable code.
What features?
* Lisp calls C and C calls lisp transparently
* no hassle in C coded functions due to GC or EVAL considerations.
* ability to hook into the read-eval-print loop without modifying the code.
* ability to extend the datatypes without modifying the code.
* mark-and-sweep or stop-and-copy GC selectable at runtime.
* readmacros
* macros
* backquote (quasi-quote)
* optionally loadable pratt (infix-language) parser
Platforms?
* VAX/VMS * VAX UNIX * SUN-3 * SUN-4 * AMIGA * MACINTOSH * MIPS * CRAY
Availability?
Anonymous FTP to BU.EDU (128.197.2.6), cd to users/gjc and get siod-v2.4-shar
(Get *HQX* files for Macintosh).
Copyright? Has MIT/X-WINDOWS style copyright notice. Free for any purpose,
including commercial use.
}
Q: Once you have a parser how do you turn off and turn on the
alternative syntax?
A1: In MACLISP and COMMON-LISP, one technique was to create
a readtable where every character, except for whitespace
perhaps, was set up to invoked the parser.
Change of syntax could be enabled by setting and/or binding
the readtable.
A2: A less pervasive technique was to use a single readmacro combination,
for example: #$, to introduce a segment of alternative syntax
inside a section of lisp code.
Q: Is there any provision in the ieee standard or R^4 for alternative
syntax hooks (e.g. readmacros).
(define (fact x) #$ if x = 0 then 1 else x * fact(x) $)
#$ fact(x) := if x = 0 then 1 else x * fact(x) $
A clever trick/convention on the lispmachine was that the readtable,
package, and the input radix, could be *bound* before a file was loaded,
by a specification at the very start of a file. The old "file mode line"
hack. Without something like that it is a bit dangerous to modify
the readtable in such a drastic way.
-gjc