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: 3 months ago
JSON representation

An interpreter for a simple Scheme-like language

Lists

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-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.