Created
October 8, 2012 19:02
-
-
Save disnet/3854258 to your computer and use it in GitHub Desktop.
start of scheme in sweet.js (modified from http://pastebin.com/0nPBg8LY)
This file contains hidden or 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
macro sexp { | |
case () => { | |
; | |
} | |
case ($p) => { | |
$p | |
} | |
case ($x $y) => { | |
$x($y); | |
} | |
case (return $x) => { | |
return $x; | |
} | |
case (display $params) => { | |
console.log($params); | |
} | |
case (define $name $body) => { | |
var $name = scheme { $body } | |
} | |
case (lambda $params $body) => { | |
function $params { scheme {$body}} | |
} | |
} | |
macro scheme { | |
case { $x } => { | |
sexp $x | |
} | |
case { $x $rest ... } => { | |
sexp $x | |
scheme { $rest ... } | |
} | |
} | |
scheme { | |
(display "hello") | |
(display "foo") | |
(define foo (lambda (a) (return "hello"))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
these macros doesn't work anymore :(