Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ingramj/bs
An interpreter for a simple Scheme-like language
https://github.com/ingramj/bs
Last synced: 2 months ago
JSON representation
An interpreter for a simple Scheme-like language
- Host: GitHub
- URL: https://github.com/ingramj/bs
- Owner: ingramj
- License: mit
- Created: 2010-01-09T23:15:43.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2010-05-13T14:01:23.000Z (over 14 years ago)
- Last Synced: 2024-08-03T18:14:19.590Z (6 months ago)
- Language: C
- Homepage:
- Size: 170 KB
- Stars: 19
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
- AwesomeInterpreter - bs
README
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-introductionUsage
=====
./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.