Skip to content

adrianwong/ponyo-bootstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ponyo-bootstrap

ponyo-bootstrap is an interpreter for a limited subset of Scheme, written in C. Its raison d'être is to bootstrap ponyo, a self-hosting Scheme-to-? compiler.

To that end, ponyo-bootstrap is a quick-and-dirty implementation, but not so quick-and-dirty such that it would make debugging Scheme programs overly difficult.

Use

$ make
$ ./ponyo

Test

$ make test

TODO

  • Implement garbage collector. (This was undertaken as a learning exercise. The changes cloud the implementation a fair bit, read this to understand why.)

Metacircular

ponyo-bootstrap can run the metacircular evaluator from SICP Chapter 4.1. This is a source of some amusement to me, as I made a start on the chapter some several years back but never got around to finishing it.

$ ./ponyo

(load "metac.scm")

;;; M-Eval input:
(define x (cons 3 (cons 2 (cons 1 '()))))

;;; M-Eval value:
ok

;;; M-Eval input:
x

;;; M-Eval value:
(3 2 1)

;;; M-Eval input:
(car x)

;;; M-Eval value:
3

;;; M-Eval input:
(cdr x)

;;; M-Eval value:
(2 1)

;;; M-Eval input:
(define y (lambda (x) (if x 'foo 'bar)))

;;; M-Eval value:
ok

;;; M-Eval input:
y

;;; M-Eval value:
(compound-procedure (x) ((if x (quote foo) (quote bar))) <procedure-env>)

;;; M-Eval input:
(y false)

;;; M-Eval value:
bar

Inspiration / Resources

About

An interpreter for a limited subset of Scheme

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published