Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eatonphil/bsdscheme
A Scheme (R7RS) implementation written in D
https://github.com/eatonphil/bsdscheme
Last synced: 3 days ago
JSON representation
A Scheme (R7RS) implementation written in D
- Host: GitHub
- URL: https://github.com/eatonphil/bsdscheme
- Owner: eatonphil
- License: bsd-3-clause
- Created: 2017-10-11T16:38:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-03T02:48:42.000Z (about 6 years ago)
- Last Synced: 2024-10-13T04:13:06.184Z (about 1 month ago)
- Language: D
- Homepage:
- Size: 128 KB
- Stars: 58
- Watchers: 4
- Forks: 2
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# BSDScheme
[![CircleCI](https://circleci.com/gh/eatonphil/bsdscheme.svg?style=svg)](https://circleci.com/gh/eatonphil/bsdscheme)
This is a Scheme implementation written in D intended to eventually
support Scheme R7RS. There is an interpreter backend which is more
mature and there is a compiler backend that targets D.## Installation
### Mac
```
$ brew install ldc
$ make
```### FreeBSD
```
$ doas pkg install ldc
$ make
```## Examples
### Recursion
```
$ cat examples/recursion-tco.scm
(define (exp base pow accum)
(if (= pow 0)
accum
(exp base (- pow 1) (* accum base))))(define (main)
(display (exp 2 100 1))
(newline))
$ ./bin/bsdi examples/exp.scm
1267650600228229401496703205376
```### Read/eval
```
$ cat examples/read-eval.scm
(display (eval (read "(+ 1 2)")))(newline)
$ ./bin/bsdi examples/read-eval.scm
3
```### REPL
```
$ ./bin/bsdi
BSDScheme v0.0.0
> (define (show it) (display it) (newline))
> (show '(1 2 3))
(1 2 3)
> (show (vector-ref #(1 2 3) 1))
2
```### Compiler (and Macros)
```
$ cat examples/my-let.scm
(define-syntax my-let*
(syntax-rules ()
((_ ((p v)) b ...)
(let ((p v)) b ...))
((_ ((p1 v1) (p2 v2) ...) b ...)
(let ((p1 v1))
(my-let* ((p2 v2) ...)
b ...)))))(define (main)
(my-let* ((a 1)
(b (+ a 2)))
(display (+ a b))
(newline)))
$ ./bin/bsdc examples/my-let.scm
$ ./a
4
```## Current state
* Supported:
* Literals: strings, characters, boolean, vectors, lists, pairs
* Read / eval / include
* Comments
* Command-line REPL
* `if`, `let`, `define`, `begin` tail calls optimized (interpreter only)
* R7RS Libraries (interpreter only)
* Basic define-syntax/syntax-rules support (not hygienic)
* Missing (but planned, R7RS is the obvious goal):
* Labelled let
* D FFI
* Threading support## Testing
BSDScheme uses the [btest](https://github.com/briansteffens/btest) test framework.