Giter Site home page Giter Site logo

ahnan4arch / bootstrap-scheme Goto Github PK

View Code? Open in Web Editor NEW

This project forked from petermichaux/bootstrap-scheme

0.0 2.0 0.0 207 KB

A quick and very dirty Scheme interpereter.

Home Page: http://peter.michaux.ca/articles/scheme-from-scratch-introduction

License: GNU Affero General Public License v3.0

Makefile 0.18% C 95.77% Scheme 4.05%

bootstrap-scheme's Introduction

Bootstrap Scheme is a quick and very dirty Scheme interpreter. Its *only* intended use is to compile a self-compiling Scheme-to-Assembly or Scheme-to-C compiler the first time.

Bootstrap Scheme doesn't have many features a Scheme system usually has. It doesn't have numbers other than integers. It doesn't have vectors. It definitely doesn't have a module system, call/cc, macros, dynamic-wind or any other advanced Scheme features.

Bootstrap Scheme is slow. The implementation is an abstract syntax tree node walker with no optimizations. There is no point in making a node walking interpreter any better than the absolute base necessity as the fundamental design of a node walker would never be used in production. Small, easy to read source code is far more important than anything else.

Bootstrap Scheme revels in the opportunity to be very dirty Scheme.

----

Example build and use.

$ cd bootstrap
$ make
cc -Wall -ansi -o scheme scheme.c
$ ./scheme
Welcome to your Scheme REPL. Use ctrl-c to exit.
> #t
#t
> -123
-123
> #\c
#\c
> "adsf"
"asdf"
> (quote ())
()
> (quote (0 . 1))
(0 . 1)
> (quote (0 1 2 3))
(0 1 2 3)
> (quote asdf)
asdf
> (define a 1)
ok
> a
1
> (set! a 2)
ok
> a
2
> (if #t 1 2)
1
> (+ 1 2 3)
6
> +
#<procedure>
> ((lamba (x) x) 1)
1
> (define (add x y) (+ x y))
ok
> (add 1 2)
3
> add
#<procedure>
> (define c ((lambda (x) (lambda () x)) 3))
ok
> (c)
3
> (begin 1 2)
2
> (cond (#f          1)
        ((eq? #t #t) 2)
        (else        3))
2
> (let ((x (+ 1 1))
        (y (- 5 2)))
    (+ x y))
5
> (and 1 2 #f 3)
#f
> (or #f #f 3 #f)
3
> (apply + '(1 2 3))
6
> (define env (environment))
ok
> (eval '(define z 25) env)
ok
> (eval 'z env)
25
> (define out (open-output-port "asdf.txt"))
ok
> (write-car #\c out)
ok
> (close-output-port out)
ok
> (load "program.scm")
program-loaded
> (error "bad move")
"bad move"
exiting
$

----

For more information see:

  http://peter.michaux.ca/articles/scheme-from-scratch-introduction

----

See the LICENSE file for legal information.

bootstrap-scheme's People

Contributors

petermichaux avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.