Commit Graph

24 Commits

Author SHA1 Message Date
Elf M. Sternberg ec9cdfb4a1 [feat] Chapter 5, first compiler. Not doing the rest... 2015-09-01 16:50:04 -07:00
Elf M. Sternberg e0b6b44178 Hey, it runs the test. It doesn't return the right value, but... 2015-08-25 22:01:21 -07:00
Elf M. Sternberg db2e93b2f3 [refactor] Is this the functor/applicative/monadic life?
This is a big change.  For chapter 5, I ripped out all line/column
tracking and most error handling from the parser; it's now a plain
ol' Lisp parser, and if it's not close to CL 22.1.1, it's a hell of
a lot closer than it used to be.

In doing so, I reduced the size of the parser by about 40 lines.

TrackingReader takes every function in a Reader and puts that
debugging information *back*.  It turns out that all that information
was prelude and postlude to the act of parsing; by wrapping each
function in a decorator I was able to restore all that information,
and I only had to get it right exactly *once*.

In functional programming terms, this lifts:

	IO -> (atom | list)

to:

	IO with tracking -> Node (atom | list) with tracking

It's a totally free win without having to do much extra work.

Now, this check-in isn't perfect.  The tracking reader is still
tossing on some things, and because I don't have a robust type
system (it is Coffeescript, after all), I'm having to do the
decorating and wrapping by hand.  But I'm definitely on my way
to understanding the issues, and having a grasp on functors and
monoids.
2015-08-20 08:50:52 -07:00
Elf M. Sternberg 00fbe22583 [feat] Chapter 4 is done. 2015-08-16 22:21:10 -07:00
Ken Elf Mathieu Sternberg ea522f6cf6 [feat] Lambda-only interpreter. NOT WORKING. 2015-08-15 18:53:24 -07:00
Elf M. Sternberg 73be7dee59 [doc] Add many comments to the final interpreter.
This adds many comments to the final interpreter, which hopefully helps
me (and anyone else reading this) understand what's going on inside the
3G interpreter.

[refactor] This last interpreter takes all the evaluate function's
"syntax" objects and moves them into a lookup table.  THis prefigures the
idea of making even the syntax malleable and extensible by future code.
I have to wonder if there's a place for making some core commands (the
"holy 7" of McCarthy, for example) un-reassignable.

Probably not.  I can vaguely see an interest in wrapping even some core
functions (car, cdr, cons) in contractual decorators.

This concludes the base homework for chapter 3.  I might get to the
exercises someday.
2015-08-07 17:09:51 -07:00
Elf M. Sternberg 38fa5ae125 [feat] The interpreter works and all the tests run without crashing. 2015-08-03 07:31:22 -07:00
Elf M. Sternberg edf8cd2c3c [bug] Unwind/Protect is not ready to be tested yet. 2015-07-31 09:40:51 -07:00
Elf M. Sternberg 32edb45f84 [feat] New interpreter needed for throwing context changes. 2015-07-31 07:48:42 -07:00
Elf M. Sternberg 3e17e69746 [refactor] Got throw/catch working with self-evaluating expressions
This was a pain point.  I had hacked the "names" of symbols into the
throw/catch representation, never appreciating how badly I was screwing
up my understanding of LiSP.  The symbols are supposed to evaluate
to something.  When they're self-evaluating expressions (strings and
numbers), those become the keys in the block stack that matter.  Getting
SEE's right, whether they're quoted or not, was really signficant.

This is cool.  Now, on to rewind/protect!
2015-07-31 07:34:12 -07:00
Elf M. Sternberg 675577431d [refactor] The great conversion continues. 2015-07-30 07:29:39 -07:00
Elf M. Sternberg 501ac5fe72 [refactor] Knuckled under and made nodes a Javascript type 2015-07-28 16:51:01 -07:00
Elf M. Sternberg 39f6a09d51 [feat] Most throw/catch conditions work.
I've hit a snag with respect to self-evaluating objects, and the ad-hoc evaluation of
program labels is messed up because of it.  I'm going to have to refactor.
Oddly enough, the strategy I hit upon appears to be the same one found
in Wisp, rather than Clojurescript.

This may actually be an internal detail; the version rendered for the user may actually
not care.  I hope not; the performance could become hairy pretty quickly.
2015-07-21 16:16:13 -07:00
Elf M. Sternberg c816fa9eb8 [chore] cleaned up after a lint pass 2015-07-08 20:46:36 -07:00
Elf M. Sternberg 1c113a2f7a [test] Tests for 'block' and 'return' added. All tests passing. W00t! 2015-07-08 20:36:56 -07:00
Elf M. Sternberg abf6c4ec50 [chore] Lint-picked versions that pass all unit tests. 2015-07-08 15:14:05 -07:00
Elf M. Sternberg bc857b19f1 [feat] The CPS-based interpreter from Chapter 3 of LiSP, with tests.
This passes all the basic tests provided from Lisp In Small Pieces,
chapter 3.  This is a functional LiSP interpreter with limited ability
and very little bug handling, but it's a solid implementation that
matches the specification and passes the tests provided for the CPS
interpreter.

This commit does *not* provide any of the continuation variants
described in the book; it is only the base interpreter.
2015-07-07 19:57:35 -07:00
Ken Elf Mathieu Sternberg 1c4975067d TEST: Add tests for the reader (!), which I had forgotten.
This also adds a number of accesory functions necessary for rationalizing
the record structure of an object in the lex/parse phase into something
more lisp-like.  There's a metadata issue here that I'm not quite wrapping
my head around.
2015-07-03 15:47:04 -07:00
Ken Elf Mathieu Sternberg 368abbf827 Moving stuff around. Broke tests. Fixed tests. 2015-07-01 13:55:22 -07:00
Elf M. Sternberg 9d9624632a Fixed test pass. Almost have CPS running. 2015-06-30 08:05:58 -07:00
Elf M. Sternberg df6f3f17ae Elf clarified test messages to distinguish interpreter cores. 2015-06-17 15:35:16 -07:00
Elf M. Sternberg b8a19d5c79 Improving test results. 2015-06-17 15:34:11 -07:00
Elf M. Sternberg b8aa463993 Updated. 2015-06-17 13:02:37 -07:00
Elf M. Sternberg f17e74207e Re-arranging for Mocha. 2015-06-17 12:34:31 -07:00