Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luohaha/eior
A compiler for Eior which is just like scheme
https://github.com/luohaha/eior
compiler lisp scheme
Last synced: 11 days ago
JSON representation
A compiler for Eior which is just like scheme
- Host: GitHub
- URL: https://github.com/luohaha/eior
- Owner: luohaha
- Created: 2016-08-23T02:54:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-24T07:59:53.000Z (over 8 years ago)
- Last Synced: 2024-11-18T13:29:43.654Z (2 months ago)
- Topics: compiler, lisp, scheme
- Language: Scheme
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Eior
A compiler for Eior which is stack-base and just like scheme. This compiler can tranfer source code to s-exprssion assembly code, and then the VM would execute it.# Usage
```
cd core/
./run [filename]
```
>You need chezScheme to run this script!# stack & register
```
;; the stack' structures
;; (top)
;; | arg1
;; | ...
;; | argn
;; | the next expression -> x
;; | the current frame -> f
;; | the current closure -> c
;; (bottom)
``````
;;register =>
;; a => accumulator
;; x => next expression
;; f => current call frame
;; c => current closure
;; s => current stack
```# support
```scheme
((let) (letrec) (if) (lambda) (quote) (set!) (call/cc) (begin))
``````scheme
((boolean?) (null?) (pair?) (number?) (char?) (string?) (symbol?) (car) (cdr) (list?) (not) (eval) (length) (display) (reverse) (zero?) (positive?) (negative?) (even?) (odd?) (log) (sin) (cos) (tan) (string->number) (number->string) (integer->char) (char->integer) (string-length))
``````scheme
((cons) (eq?) (+) (equal?) (-) (*) (/) (=) (>) (<) (>=) (<=) (and) (or) (eqv?) (memq) (memv) (member) (assq) (assv) (assoc) (mod) (char=?) (char) (char>?) (char<=?) (char>=?) (string) (string>?) (string=?) (string<=?) (string>=?) (string-append))
```# example
* list-ref
```scheme
(letrec ([list-ref
(lambda (lst x)
(if (= x 0)
(car lst)
(list-ref (cdr lst) (- x 1))))])
(list-ref '(a b c d) 1))
```* fibonacci
```scheme
(letrec ([fib-iter (lambda (a b count)
(if (= count 0)
b
(fib-iter (+ a b) a (- count 1))))])
(let ([fib (lambda (n)
(fib-iter 1 0 n))])
(fib 100)))
```# reference
* Three Implementation Models for Scheme - R. Kent Dybvig
* Structure and Interpretation of Computer Programs - Abelson, H. and Sussman, G
* Essentials of Programming Languages - Daniel P. Friedman Mitchell Wand