birth,rebirth: Add cond-expand, string->es

`cond-expand' allows moving forward with implementing features based on the
current bootstrapped state of the system---rebirth will be able to
recursively compile itself and introduce new features along the way.

`string->es' allows outputting raw ECMAScript, which gives us more control
over the code that is generated without having to hard-code it in the
compiler itself.

* build-aux/bootstrap/birth.scm
  (fnmap)[cond-expand]: Always yield the empty string (do nothing).
* build-aux/bootstrap/rebirth.scm
  (fnmap)[cond-expand]: Expand `string->es' only.
  (fnmap)[string->es]: Add macro.
master
Mike Gerwitz 2017-12-05 00:35:54 -05:00
parent 4702184c33
commit 639948da02
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
2 changed files with 17 additions and 0 deletions

View File

@ -377,6 +377,10 @@
(("js:console")
(string-append "console.log(" (map sexp->es args) ")"))
;; always expands into nothing; this is just to facilitate its use
;; moving forward
(("cond-expand") "")
;; yes, there are more important things to do until we get to the
;; point where it's worth implementing proper tail calls
(("js:while")

View File

@ -398,6 +398,19 @@
(("js:console")
(string-append "console.log(" (map sexp->es args) ")"))
;; very primitive cond-expand
(("cond-expand")
(let* ((clause (car args))
(feature (token-value (car clause)))
(body (cdr clause)))
(case feature
(("string->es") (body->es body #f))
(else ""))))
;; output raw code into the compiled ECMAScript (what could go wrong?)
(("string->es")
(token-value (car args)))
;; yes, there are more important things to do until we get to the
;; point where it's worth implementing proper tail calls
(("js:while")