Created
April 15, 2017 09:02
-
-
Save ympbyc/56b50762520bd8ca875911ee7d713993 to your computer and use it in GitHub Desktop.
rough sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-1) | |
(define (mlf-symbol sym) | |
(string->symbol (string-append "$" (symbol->string sym)))) | |
(define (compile expr) | |
(cond | |
[(number? expr) expr] | |
[(string? expr) (string-append "\"" expr "\"")] | |
[(symbol? expr) (mlf-symbol expr)] | |
[(eq? (car expr) 'quote) (cadr expr)] | |
[(eq? (car expr) '^) | |
(list 'lambda | |
(map mlf-symbol (drop-right (cdr expr) 1)) | |
(compile (last expr)))] | |
[#t (append (list 'apply | |
(compile (car expr))) | |
(map compile (cdr expr)))])) | |
(define (main args) | |
(list 'module | |
(list '_ (list 'apply '(global $Pervasives $print_string) (compile (read)))) | |
'(export)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment