Commit Graph

67 Commits (34518e15320cfb01bdaa88b363a23d2c424971d6)

Author SHA1 Message Date
Mike Gerwitz b5f70fd8a6
birth: Add birth.scm, which can parse itself and output a CST
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!
2017-08-31 01:01:06 -04:00
Mike Gerwitz 866139e60a
prebirth: Scheme-like truth test for `if' form
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.
2017-08-31 00:48:18 -04:00
Mike Gerwitz 512780eafe
prebirth: Add `and', `or', and `case' special forms
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.
2017-08-31 00:48:02 -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 fe80b398b5
prebirth: Correct token value parsing
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.
2017-08-30 00:25:43 -04:00
Mike Gerwitz 59daf7a5b5
prebirth: Wrap `if' applications
* build-aux/bootstrap/prebirth.js (fnmap)[if]: Wrap generated code
    in self-executing function.
2017-08-30 00:25:32 -04:00
Mike Gerwitz dcc6aed322
prebirth: Add newlines between body expressions
Just makes it easier to look at for debugging.

* build-aux/bootstrap/prebirth.js (Compiler#_bodyToEs): Add newlines.
2017-08-30 00:00:39 -04:00
Mike Gerwitz ef4f70bf96
prebirth: Initial function map
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.
2017-08-30 00:00:22 -04:00
Mike Gerwitz 61f6ba1470
prebirth: Distinguishable id generation
* build-aux/bootstrap/prebirth.js (Compiler#_idFromName): Distinguish
  between certain types of characters.
2017-08-29 23:59:49 -04:00
Mike Gerwitz 6a736a8fcd
prebirth: Ignore comments in JS parser
* build-aux/bootstrap/prebirth.js (parseLisp): Ingore comment tokens.
  (_lex): Recognize comments.
2017-08-29 01:27:54 -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
Mike Gerwitz f2adafb264
prebirth: Allow toplevel function applications
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.
2017-08-28 01:21:02 -04:00
Mike Gerwitz f23396de2e
prebirth: Abandon `define-block' in favor of `define'
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.
2017-08-28 00:53:02 -04:00
Mike Gerwitz c0fb8297a6
Prebirth: Add docstring
* build-aux/bootstrap/prebirth.js (Compiler#_docstring): Add method.
  (Compiler#_cdfn): Use it.
2017-08-21 02:39:33 -04:00
Mike Gerwitz 7998296a20
Add prebirth.js
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.
2017-08-21 02:20:10 -04:00
Mike Gerwitz ecd8b6d9e7
Add README.md and COPYING 2017-08-21 02:19:36 -04:00