Commit Graph

82 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 65476fecaf [feat] Booleans work. Symbols work (sort-of). 2015-08-29 22:30:29 -07:00
Elf M. Sternberg 356d4561b2 Basic arithmetic works! 2015-08-29 21:45:36 -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 981baec645 Start of chapter 5 interpreters. New readers, too. 2015-08-18 07:09:47 -07:00
Elf M. Sternberg 00fbe22583 [feat] Chapter 4 is done. 2015-08-16 22:21:10 -07:00
Elf M. Sternberg d49f07911c Frantically fitting. This isn't elegant. 2015-08-16 11:31:52 -07:00
Ken Elf Mathieu Sternberg ea522f6cf6 [feat] Lambda-only interpreter. NOT WORKING. 2015-08-15 18:53:24 -07:00
Elf M. Sternberg 1e38327b2a Beginning Chapter 4. 2015-08-15 09:43:48 -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 bf7068d0ad [feat] unwind-protect now works. Tracked down the last bad reference. 2015-08-04 08:48:12 -07:00
Elf M. Sternberg d26c572ba2 [bug] Tracked down the misassignment in my original. All tests passing. 2015-08-03 16:23:30 -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 746f92fcdb [refactor] Extended node refactor to Chapter 3 2015-07-27 21:53:14 -07:00
Elf M. Sternberg 5d9703aa33 [refactor] A new representation for symbols to handle quoted code
This is a big refactoring; the parser is now modal, to handle either
complex Node objects that carry around a lot of state with them, or
simpler objects that represent the McCarthy-style IST.  I'm still
feeling my way through the subject material.  The node construction
is such pure artifice I feel silly keeping it, and may end up revising
it (again).

The nice thing is, everything goes through evaluate.  Almost no other
code needs to know anything at all about the shape of the Nodes themselves;
it all makes assumptions based on the return value (or continuation passed)
by evaluate.
2015-07-27 21:27:21 -07:00
Elf M. Sternberg 02f79c4255 [refactor] Struggling to get self-evaluating components working. 2015-07-26 14:59:49 -07:00
Elf M. Sternberg 5bba101ee2 [refactor] Custom reader types have unique Javascript equivalents now. 2015-07-24 07:44:04 -07:00
Elf M. Sternberg bb0c06b073 Reverting back to working version. 2015-07-23 16:21:28 -07:00
Elf M. Sternberg e6b4a73559 Fail. 2015-07-23 16:17:20 -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 5e8172d233 [feat] labeled 'block' and 'return' added! Woot! 2015-07-08 20:35:55 -07:00
Elf M. Sternberg 07a800cfbf [docs] Updated blog message with addenda from site. 2015-07-08 15:16:59 -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 111ad5d8dc [test] Coffeelint configuration file. 120 character line length is okay by me. 2015-07-08 15:06:06 -07:00
Elf M. Sternberg de3aa61e22 [test] Added Coffeelint to list to of features. 2015-07-08 15:04:32 -07:00
Elf M. Sternberg 8cf6e4fb5b [feat] Added 'watch' to list of Makefile targets
'Watch' depends upon the inotify toolkit; it will automagically
run the test suite locally every time you press "save".
2015-07-08 14:47:04 -07:00
Elf M. Sternberg b9a60e3fed [doc] Including blog entry for Chapter 3
As a chronic blogger, I've been updating my journey on my website
at http://elfsternberg.com.  This is where the original markdown
files are kept.
2015-07-08 14:45:59 -07:00
Elf M. Sternberg 1a777acb4c [docs] Including Jenkins configuration file
This file is highly localized for my personal set-up.  If you want to
run Jenkins yourself, you *will* have to edit it, or use it as an example
in your own set-up.
2015-07-07 20:27:11 -07:00
Elf M. Sternberg 7bd66b6080 [docs] That *is* coffee! 2015-07-07 20:22:19 -07:00
Elf M. Sternberg 983f29c1eb [docs] Updating the README to be more... well, just *more* 2015-07-07 20:19:04 -07:00
Elf M. Sternberg b4f5add0b8 [docs] Updating the README to be more... well, just *more* 2015-07-07 20:17:57 -07:00
Elf M. Sternberg 1676584db2 [docs] Updating the README to be more... well, just *more* 2015-07-07 20:17:13 -07:00
Elf M. Sternberg fb7dab6b33 [chore] Removed a symbolic link that went nowhere. 2015-07-07 20:01:59 -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
Elf M. Sternberg 560bcd4dda [bug] Fixed the reader to handle dotted lists.
This support is ugly and probably incorrect, but it passes all the current
tests and handles test cases in the original documentation.
2015-07-07 19:56:11 -07:00
Elf M. Sternberg 8572d84817 Merge fix. 2015-07-04 15:28:56 -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 254c1c0f60 FEAT: Completed chapter 3 interpreter implementation. 2015-07-03 15:45:37 -07:00
Elf M. Sternberg f711432626 Updating. 2015-07-03 12:58:08 -07:00
Elf M. Sternberg c2ff0a3d88 Added some comments. 2015-07-02 17:21:50 -07:00
Ken Elf Mathieu Sternberg 51ae30e31f Thinking about that chapter 3 interpreter from the book. 2015-07-01 17:38:31 -07:00
Ken Elf Mathieu Sternberg 368abbf827 Moving stuff around. Broke tests. Fixed tests. 2015-07-01 13:55:22 -07:00