-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
131 lines (116 loc) · 2.5 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
bs - A Basic Scheme Implementation
==================================
bs is an interpreter for a simple Scheme-like language. It lacks the more
advanced features of Scheme, such as macros and call/cc.
The goal of bs is to implement enough of Scheme to boostrap a Scheme compiler
written in Scheme. A secondary goal is to learn about writing simple
interpreters.
This project was inspired by Peter Michaux's "Scheme from Scratch" project.
http://peter.michaux.ca/articles/scheme-from-scratch-introduction
Usage
=====
./bs file [-p]
Where "file" is either a Scheme source file, or a "-" to read from stdin.
"-p" causes bs to print the result of every expression it evaluated.
There is a read-eval-print loop in the file bsrepl.scm. To use it, just run
"./bs bsrepl.scm"
Features Implemented
====================
Data types:
integers
booleans
characters
strings
pairs and lists
ports
Special Forms:
quote and '
define
set!
if
cond
lambda
let
begin
and
or
Primitives:
eq?
null?
boolean?
symbol?
integer?
char?
string?
pair?
list?
procedure?
input-port?
output-port?
eof-object?
+
-
*
quotient
remainder
=
<
>
cons
car
set-car!
cdr
set-cdr!
length
list
char->integer
integer->char
number->string
string->number
symbol->string
string->symbol
current-input-port
current-output-port
open-input-file
open-output-file
close-input-port
close-output-port
read
read-char
write
write-char
display
stdin-port
stdout-port
load
error
apply
eval
interaction-environment
null-environment
environment
In stdlib.scm:
number?
map
for-each
fold-right
fold-left
reverse
append
not
newline
call-with-input-file
call-with-output-file
caar, cddr, etc.
Compilation
============
To build bs, you'll need libgc and scons. Assuming you already have gcc
installed, you can install the neccessary packages on a Debian-based system
with this command:
$ sudo apt-get install libgc-dev scons
Then type "scons" in the project directory to build bs.
If you are using a non-Debian-based system, or a different compiler, you'll
probably need to edit the SConstruct file.
There is a simple test script in the tests/ directory. Look at the comments at
the top of run-tests.sh for details.
See the LICENSE file for copyright and licensing information.