Commit Graph

11 Commits (ec43d7717aded36e9f2984a2d55ba41f40a796ed)

Author SHA1 Message Date
Mike Gerwitz 1060247f0b
prebirth, birth, rebirth: Consistently use "es" instead of "js"
I've been torn on this for a bit, but we're using "es" (ECMAScript) in a lot
of important places.  Thinks like "js:console" I was considering leaving
because "console" is not an ECMAScript thing---it is JavaScript.  But now we
will take "es:" to mean "outputting in ECMAScript".

* build-aux/bootstrap/birth.scm, build-aux/bootstrap/rebirth.scm,
  build-aux/bootstrap/prebirth.js:
    s/js:/es:/g.
* build-aux/bootstrap/libprebirth.js: s/\$\$js\$/\$\$es\$/g.
2017-12-12 01:03:37 -05:00
Mike Gerwitz 4702184c33
libprebirth: Remove unused `append!'
* build-aux/bootstrap/libprebirth.js
  ($$append$b$): Remove function.
  ($$append): Fix whitespace.
2017-12-05 00:33:34 -05:00
Mike Gerwitz 6138731304
bootstrap: Formalize (both command-line and browser)
This allows bootstrapping in either a development environment (Node.js) or
simply using the intended runtime environment: the user's browser.

* bootstrap.html: Add file (browser).
* bootstrap.js: Add file (command-line).
* bootstrap/Bootstrap.js: Add class.  Formalize bootstrap process.
* bootstrap/libprebirth.js
  (fsdata): Add variable to serve as filesystem stub.
  (fs): Always throw error when `fs' module is unavailable.
  ($$js$file$_$$g$string): Consider `fsdata'.
* bootstrap/prebirth.js: Export as CommonJS module if in proper
    environment.  Abort automatic processing via stdin if root CommonJS
    module.
2017-11-12 00:29:40 -05:00
Mike Gerwitz 431b18e1df
birth,prebirth: Non-recursive lexing to prevent stack exhaustion
This needs to run in the browser too, where we have no control over stack
limits.

* build-aux/bootstrap/birth.scm
  (lex): Non-recursive strategy (loop with mutable list).
  (make-token): Update doc.  Produce list of token, new string, and
    position.  Don't recurse.
  (body->es): Add `ret' param.  Only produce `return' statement if new param
    is set.
  (cdfn): Use it.
  (fnmap)
    [js:while, js:break]: Add forms.
    [lambda, let, case]: Use new `body->es' `ret' param.
    [let*]: Define JS variables in output using `let' instead of `const' to
      permit mutating with new `set!' form.  Use new `body->es' `ret' param.
    [set!]: Add form.
  (prebirth->ecmascript): Adjust libprebirth path to be relative to self.

* build-aux/bootstrap/libprebirth.js
  ($$append$b$): Add `append!' procedure.
  ($$js$regexp, $$js$match, $$js$replace): Move a few lines up.
  (fs): Provide stub if `require' is not defined.

* build-aux/bootstrap/prebirth.js
  (_lex): Non-recursive strategy (loop with array-appending).
  (_token): No more mutual recursion with `#_lex'.  Return new string
    and position.
  (_bodyToEs): Add `ret' param.  Only produce `return' statement if new
    param is set.
  (fnmap) [js:while, js:break]: Add forms.
    [let*]: Define JS variables in output using `let' instead of `const' to
      permit mutating with new `set!' form.  Use new `body->es' `ret' param.
    [set!]: Add form.
2017-10-18 02:41:43 -04:00
Mike Gerwitz 35fa13a8a0
birth: Prebirth self-hosting
This completes bootstrapping for Prebirth Lisp.  The next step will be
Rebirth, which will replace libprebirth.js, removing hand-written JavaScript
entirely.
2017-10-09 21:22:59 -04:00
Mike Gerwitz 3310241a94
birth: AST generation
Just about ready for that sloppy code generation!

* build-aux/bootstrap/birth.scm: Update file header documentation.
  Add some whitespace between existing procedures.
  Invoke `parse-lisp' as the program in place of `lex', producing an AST as
    output to the console.
  (cadddr): Add procedure.
  (token-{type,lexeme,value,pos}): Add procedures.
  (parse-lisp): Add procedure (contains other procedures).
* build-aux/bootstrap/libprebirth.js
  ($$append): Add function (append).
  ($$$_$): Correct implementation (-).
  ($$zero$7$): Add predicate (zero?).
  ($$fold): Add function (fold).
* build-aux/bootstrap/prebirth.js (parseLisp): Lowercase some errors.
  (Compiler): Update class docblock.
  (fnmap)[labmda]: Add `lambda' form.
2017-09-02 01:30:13 -04:00
Mike Gerwitz b58bbe3949
prebirth: Add `-' to libprebirth
* build-aux/bootstrap/libprebirth.js ($$$_$): Add function.
2017-08-31 12:43:42 -04:00
Mike Gerwitz 41bf925b4e
prebirth: Add `string-append' to libprebirth
* build-aux/bootstrap/libprebirth.js ($$string$_$append): Add function.
2017-08-31 12:42:25 -04:00
Mike Gerwitz f626891e75
prebirth: More substantial libprebirth
This is a decent start.

* build-aux/bootstrap/libprebirth.js: Add a lot of stuff.  Go look for
  yourself.
2017-08-31 00:47:57 -04:00
Mike Gerwitz 3c5089417c
prebirth: Globally unique functions
This was implicit in the `define-block' implementation because of the
conversion from `<foo>' to `$foo$', but that's no longer the case.

This is just a simple, temporary implementation, so don't be alarmed.

* build-aux/bootstrap/libprebirth.js: Updated header documentation to
    mention `$$' prefix.
  ($$js$console): Renamed from `js$console'.
* build-aux/bootstrap/prebirth.js
  (_idFromName): Add `global' parameter to add `$$' prefix to generated
    identifiers.
  (_cdfn, _sexpToEs): Use it.
2017-08-28 23:42:19 -04:00
Mike Gerwitz 19642e59d9
prebirth: Prepend libprebirth to output
* build-aux/bootstrap/libprebirth.js: Add file.
* build-aux/bootstrap/prebirth.js: Prepend `libprebirth.js' contents to
  output.
2017-08-28 01:22:51 -04:00