Skip to content

Commit 613210f

Browse files
committed
initial commit
1 parent 2f606a9 commit 613210f

File tree

12 files changed

+11154
-0
lines changed

12 files changed

+11154
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# make generated files
2+
lemon
3+
yocto
4+
yocto-lexer.c
5+
yocto-parser.c
6+
yocto-parser.h
7+
8+
# random scheme files
9+
*.scm

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# just build the thing fast
2+
#CFLAGS = -Wall -lm -DNDEBUG
3+
4+
# smallest size
5+
CFLAGS = -Os -s -Wall -Wl,-z,norelro -DNDEBUG -lm
6+
7+
# debug
8+
#CFLAGS = -g -Wall -lm
9+
10+
all : yocto
11+
12+
yocto : yocto.c yocto.h yocto-lexer.c yocto-parser.c Makefile
13+
$(CC) $(CFLAGS) -o yocto yocto-lexer.c yocto-parser.c linenoise/linenoise.c yocto.c
14+
15+
yocto-lexer.c : yocto-lexer.re
16+
re2c -i -o yocto-lexer.c yocto-lexer.re
17+
18+
yocto-parser.c : lemon yocto-parser.y
19+
./lemon -q -l yocto-parser.y
20+
21+
lemon : lemon.c
22+
$(CC) -o lemon lemon.c
23+
24+
clean :
25+
rm -f yocto-lexer.c yocto-parser.c yocto-parser.h lemon yocto
26+

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
## Yocto Scheme
2+
---------------
3+
4+
An over-engineered port of MiniScheme aiming for R4RS compliance but mostly
5+
just a playground to learn how to put together a working lexer/parser stack.
6+
7+
* re2c for lexing
8+
* lemon for parsing
9+
* linenoise for command line history/editing.
10+
11+
### Credits
12+
13+
Mini-Scheme Interpreter Version 0.85
14+
15+
coded by Atsushi Moriwaki (11/5/1989)
16+
E-MAIL : moriwaki@kurims.kurims.kyoto-u.ac.jp
17+
This version has been modified by R.C. Secrist.
18+
19+
Mini-Scheme is now maintained by Akira KIDA.
20+
21+
This is a revised and modified version by Akira KIDA.
22+
current version is 0.85k4 (15 May 1994)
23+
24+
THIS SOFTWARE IS IN THE PUBLIC DOMAIN
25+
26+
This software is completely free to copy, modify and/or re-distribute.
27+
But I would appreciate it if you left my name on the code as the author.
28+
29+
Some (a lot of) code ported from TinyScheme
30+
31+
lcm & gcd in init.scm from stalin
32+
33+
### Compile Time Dependencies
34+
35+
re2c >= 1.0.3
36+
37+
lemon parser generator source is in tree
38+
39+
linenoise included as a git submodule
40+
41+
### Known Bugs
42+
43+
- [ ] quasiquote macro doesn't work inside a vector
44+
- [ ] #| comments |# overflow the input buffer
45+
46+
### TODO
47+
48+
#### 6.5.5. Numerical operations
49+
- [ ] numerator
50+
- [ ] denominator
51+
- [ ] rationalize
52+
- [ ] make-rectangular
53+
- [ ] make-polar
54+
- [ ] real-part
55+
- [ ] imag-part
56+
- [ ] magnitude
57+
- [ ] angle
58+
59+
#### 6.7. Strings
60+
- [ ] string-set!
61+
- [ ] string=?
62+
- [ ] string-ci=?
63+
- [ ] string<?
64+
- [ ] string>?
65+
- [ ] string<=?
66+
- [ ] string>=?
67+
- [ ] string-ci<?
68+
- [ ] string-ci>?
69+
- [ ] string-ci<=?
70+
- [ ] string-ci>=?
71+
- [ ] substring
72+
- [ ] string-append
73+
- [ ] string->list
74+
- [ ] list->string
75+
- [ ] string-copy
76+
- [ ] string-fill!
77+
78+
#### 6.10.1. Ports
79+
- [ ] call-with-input-file
80+
- [ ] call-with-output-file
81+
- [ ] with-input-from-file
82+
- [ ] with-output-to-file
83+
- [ ] open-input-file
84+
- [ ] open-output-file
85+
- [ ] close-input-file
86+
- [ ] close-output-file
87+
88+
#### 6.10.2. Input
89+
- [ ] read-char
90+
- [ ] peek-char
91+
- [ ] eof-object?
92+
- [ ] char-ready?
93+
94+
#### 6.10.4. System interface
95+
- [ ] transcript-on
96+
- [ ] transcript-off
97+

README.minischeme

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
=====================================================================
2+
3+
---------- Mini-Scheme Interpreter Version 0.85 ----------
4+
5+
coded by Atsushi Moriwaki (11/5/1989)
6+
7+
E-MAIL : moriwaki@kurims.kurims.kyoto-u.ac.jp
8+
MIX : riemann
9+
NIFTY : PBB01074
10+
(Note that these addresses are now obsolete, see below)
11+
12+
=====================================================================
13+
14+
Revised by Akira KIDA
15+
16+
Version 0.85k4 (17 May 1994)
17+
Version 0.85k3 (30 Nov 1989)
18+
Version 0.85k2 (28 Nov 1989)
19+
Version 0.85k1 (14 Nov 1989)
20+
21+
Mini-Scheme is now maintained by Akira KIDA.
22+
23+
E-Mail : SDI00379@niftyserve.or.jp
24+
25+
Most part of this document is written by Akira KIDA.
26+
Send comments/requests/bug reports to Akira KIDA at the above
27+
email address.
28+
29+
=====================================================================
30+
31+
This Mini-Scheme Interpreter is based on "SCHEME Interpreter in
32+
Common Lisp" in Appendix of T.Matsuda & K.Saigo, Programming of LISP,
33+
archive No5 (1987) p6 - p42 (published in Japan).
34+
35+
36+
Copyright Notice:
37+
THIS SOFTWARE IS PLACED IN THE PUBLIC DOMAIN BY THE AUTHOR.
38+
39+
This software is completely free to copy, modify and/or re-distribute.
40+
But I (Atsushi Moriwaki) would appreciate it if you left my name on the
41+
code as the author.
42+
43+
DISCLAIMER:
44+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
45+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
46+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47+
PURPOSE.
48+
49+
50+
Supported features (or, NOT supported features :-)
51+
1) Lists, symbols, strings.
52+
However, strings have very limited capability.
53+
For instance, there is *NO* string-ref, string-set!, ... etc.
54+
2) Numbers are limited to FIXNUM only.
55+
There is *NO* complex, real, rational and even bignum.
56+
3) Macro feature is supported, though not the one defined in R4RS.
57+
58+
Known problems:
59+
1) Poor error recovery from illegal use of syntax and procedure.
60+
2) Certain procedures do not check its argument type.
61+
62+
Installation:
63+
1) Select system declaration and configuration options by editing
64+
source file.
65+
66+
You may choose one of the following systems by #define'ing
67+
the preprocessor symbol.
68+
69+
Supported systems are:
70+
Macintosh:
71+
LSC -- LightSpeed C (3.0) for Macintosh
72+
LSC4 -- LightSpeed C (4.0) for Macintosh
73+
They are different in #include header only.
74+
I (kida) think THINK C 5.0, 6.0, 7.0 may be OK
75+
with LSC4 configuration, though not tested.
76+
MPW2 -- Macintosh Programmer's Workshop v2.0x
77+
I don't tested v3.x or later.
78+
DOS:
79+
MSC4 -- Microsoft C v4.0 (use /AL)
80+
MSC v5.1, v6.0, v7.0 are all OK.
81+
TURBO2 -- Bolarnd's Turbo C v2.0 (use -ml)
82+
Turbo C++ 1.0 is OK.
83+
UNIX:
84+
BSD -- UNIX of BSD flavor, ex. SuOS 4.x
85+
SYSV -- UNIX of System-V flavor, ex. Sun/Solaris 2.x
86+
87+
VAX/VMS:
88+
VAXC -- VAX-C v3.x (this symbol may be defined by the
89+
compiler automatically).
90+
91+
2) Configure some preprocessor symbols by editing source files.
92+
93+
Configurable #define's are:
94+
95+
#define VERBOSE
96+
-- if defined, GC messages is verbose on default.
97+
98+
#define AVOID_HACK_LOOP
99+
-- if defined, do _NOT_ use loop construction in the
100+
form
101+
do { ... } while (0)
102+
This form is used in macro expansion, since this is
103+
the best "safety" blocking construct when used in
104+
macro definition.
105+
However, some compiler (including SunPRO CC 2.0.1)
106+
is silly enough to warning this construct, like
107+
"warning: end-of-loop code not reached", etc.
108+
If you dislike such warning, please define this symbol.
109+
NOTE: You may get some "statement not reached" warning
110+
even if you have define this symbol. Please be patient,
111+
or, use more smart compiler.
112+
In short if you use GCC, undefine this and forget it
113+
at all.
114+
115+
#define USE_SETJMP
116+
-- if defined, use setjmp to global jump on error.
117+
if not defined, avoid to use it. Compiled with
118+
this symbol defined, the interpreter issue fatal
119+
error and return to the operating system immediately
120+
when we run out of free cells. By default, i.e.,
121+
compiled with this symbol is not defined, the
122+
interpreter will just return to the top level in
123+
such a case.
124+
May not be used except for compiling as Mac DA.
125+
126+
#define USE_MACRO
127+
-- if defined, macro features are enabled.
128+
129+
#define USE_QQUOTE
130+
-- if defined, you can use quasi-quote "`" in macro.
131+
You can use macro even if this symbol is undefined.
132+
133+
3) Compile!
134+
135+
I think there is virtually no problem about how to compile.
136+
Since there is exactly one C source file. :-)
137+
If you are on UNIX boxes with some BSD flavors, instead of
138+
using make command, it's enough to type:
139+
140+
cc -DBSD -O -o miniscm miniscm.c
141+
142+
You may have additional warnings like 'function should
143+
return value'. This is due to omitting 'void' keyword
144+
from the source in order to get pre-ANSI compatibility.
145+
146+
147+
Usage : miniscm
148+
149+
Sorry, no command line argnumet is allowed.
150+
151+
152+
Special procedures of this system:
153+
154+
gc : (gc) -- force garbage collection
155+
156+
gc-verbose : (gc-verbose bool) -- GC verbose on/off
157+
Argument #f turnes off the GC message.
158+
Enything else turn on the GC message.
159+
160+
quit : (quit) -- quit to the operating system
161+
162+
put : (put sym prop expr)
163+
-- set the value of a property of a symbol.
164+
get : (get sym prop)
165+
-- get the value of a property of a symbol.
166+
167+
new-segment : (new-segment n)
168+
-- allocate n new cell segments.
169+
170+
print-width : (print-width list)
171+
-- returns 'printed' width of list.
172+
173+
closure? : (closure? obj)
174+
-- test if obj is a closure or not.
175+
176+
macro? : (macro? obj)
177+
-- test if obj is a macro or not.
178+
note that a macro is also a closure.
179+
180+
get-closure-code
181+
: (get-closure-code closure-obj)
182+
-- extract S-expr from closure-obj.
183+
184+
Scheme files:
185+
init.scm -- Automatically loaded at invocation.
186+
Default setting assumes that this file is in the current
187+
working directory.
188+
Change #define InitFile if you don't like it.
189+
190+
tools.scm -- This is a sample file. Contains very tiny pretty-print
191+
procedure.
192+
After invoking miniscm, type:
193+
(load "tools.scm")
194+
and try
195+
(pp getd)
196+
(pp do)
197+
198+
Documents?:
199+
200+
Sorry, there is no other documents.
201+
Do not ask one for me, please see the source instead. :-)
202+
203+
But if you _absolutely_ need help, please email to me at:
204+
<SDI00379@niftyserve.or.jp>
205+
206+
Enjoy!
207+
208+
-- Akira KIDA
209+
Sysop for FPL in NIFTY-Serve in JAPAN.
210+
(FPL stands for 'Forum for Program-Language')
211+

0 commit comments

Comments
 (0)