This completes bootstrapping for Prebirth Lisp. The next step will be
Rebirth, which will replace libprebirth.js, removing hand-written JavaScript
entirely.
* build-aux/bootstrap/prebirth.js
(_cdfn): Remove second argument to `#_idFromName'.
(_idFromName): Remove second parameter `global'. Identify and echo
integers. Remove distinction between global and non-global
identifiers---process everything.
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.
This just reorganizes things slightly to allow for nested `define's. This
is a common means of encapsulation, and will Just Work™ because JS has
pretty much identical block scoping rules in this regard.
* build-aux/bootstrap/prebirth.js (compile): Invoke `#_sexpsToEs' directly
instead of `#_cdfn' on tree.
(_cdfn): Remove non-`define' check to proxy to `#_sexpsToEs'.
(_sexpsToEs): Treat `define' as a special case, invoking `#_cdfn'.
Exciting first step! Though it required a much more complicated Prebirth
Lisp than I was hoping to create. And I never intended to go into a full
Scheme implementation, but that's the route this is headed in. I just can't
stomach creating this full system in a block language.
With that said, the block language will still be able to work with all Lisp
code; you'll see.
* build-aux/bootstrap/birth.scm: Add beginning of Birth, capable of parsing
itself! Baby steps!
Already implemented by `case', `or', `and'.
* build-aux/bootstrap/prebirth.js (fnmap)[if]: Use proper truth check, as
expected by RnRS Scheme. For JS, this means only `false' is non-true.
So much for simple. But it's not worth my suffering to not add them.
* build-aux/bootstrap/prebirth.js (fnmap): Add more information to docblock.
(and, or, case): Add special forms.
Empty string was not matching, which was causing its value to be '""', which
expanded (in JS) into the compiled string '""""'. Oops.
* build-aux/bootstrap/prebirth.js (Parser#_token): Distinguish empty values
from non-matches.
The Prebirth JS compiler is getting much more sophisticated than I had
hoped, but I need something to work with here. This starts to get us
in a good spot.
There are other conveniences I will want. More to come.
* build-aux/bootstrap/prebirth.js
(Compiler#constructor): Add method, accept fnmap.
(Compiler#_sexpToEs): Use fnmap as needed.
(fnmap): Add initial map.
Instantiate `Compiler' with fnmap.
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.
So we can invoke the main function for the program.
* build-aux/bootstrap/prebirth.js
(Compiler#_cdfn): Handle non-`define' applications.
(Compiler#assertApply): Remove function.
Turns out, I'll kill myself before writing a Prebirth compiler in a
block-define-based Prebirth Lisp. So, let's degrade even further into a
primitive Scheme. This is going down a dangerous path to simply
implementing Scheme...
Nonetheless, here I remove `define-block' in favor of a simple shorthand
function definition `define', as is custom in Scheme. We will worry
about block definitions later as metadata mapping to normal functions.
This is hopefully the beginning of a good thing that I'll actually
finish. I began planning this project formally just before the beginning of
Aug 2017.
* build-aux/bootstrap/prebirth.js: New file.