Language Project
Code on GitHub
Install:
$ git clone https://github.com/olleicua/hot-cocoa
$ git clone https://github.com/olleicua/hcl
$ cd hcl
$ ln -s ../hot-cocoa node_modules/hot-cocoa
# the above could be done for you by npm or, alternately a global install of hot-cocoa.
Test:
$ ./node_modules/hot-cocoa/bin/testrunner.js
$ ./bin/hcl examples/fizzbuzz.hcl
$ node examples/fizzbuzz.js
Timeline
Feb 5: General purpose code nearing a completed state
Feb 19: Documentation for the general purpose code drafted
Feb 26: Lisp language near complete
March 5: Lisp language documentation drafted
March 12: Documentation and final write-up drafts
BREAK
...
January 29
My project has evolved a bit over winter break. At this point I have a working set of general purpose tools for implementing languages in Node.js as an NPM library. My library features a tokenizing system, a parser, a test suite, a string formatting/templating system, tools for structuring language templates, and tools for semantic analysis. Some of these will need small tweaks/improvements. I also have an implementation of the lisp-like language I've been working on this past semester using these tools that is at about 90%. There are features that I want to add and there are details to clean up but the basics are there and it can compile a somewhat non-trivial recursive fizzbuzz program.
Feb 5
See attached.
Feb 12
I still need to work out how introspection is going to function. I have some ideas but they need a bit of development. I hope we can talk about them today.
Feb 19
Talked briefly about exam ; no other progress this week. (Flurry!)
Feb 28
I have been working steadily on the docs which should be in decent draft-like state by next week. I've made a few incremental improvements to the language and in the course of using the language for an exam question I've discovered a feature that would be quite useful to add. When building large projects that have dependencies in multiple files the compile-test-loop can end up being something like:
$ hcl dependency1.hcl && hcl dependency2.hcl && hcl main.hcl && node main.js
This can get a bit cumbersome so I'm considering adding a language primitive called something like source that would take a path to an .hcl source file and make sure that it's corresponding .js file is up to date then return the path to the .js file. Then the inclusion of something like:
(require (source "dependency1.hcl"))
would automatically instruct the compiler to recompile the dependency.
So far I've really only been working in the context of the Node.js CLI and it seems like it would be sensible to implement a way to instruct the compiler to create source designed to work in a browser. This would mean a few things:
- Adding a function wrapper to encapsulate the script.
- Adding functionality that is not universally supported by browsers like Object.create
- Making a Node.js style require available by inserting the compiled source of the dependency into the same file via a function wrapper to preserve scope.
Apart from the two above features, I still plan to make some improvements to the annotations and fix some problems that still exist with the way that variables are initialized.
March 5
I've implemented the dependency system I was talking about last week:
$ cd hcl-directory
$ git pull
$ ./bin/hcl examples/dependencies.hcl
$ node examples/dependencies.js
I've created a simplified version of the case where my project was failing here:
https://gist.github.com/olleicua/5087130. As the gist suggests, the bug can be eliminated by moving one of the requires inside of a closure where it is being used. This works because it guarantees that particular require won't be loaded later when the module will have been processed to the point of containing the expected function. I've added preliminary documentation in the code explaining the fix.
I've also made various smaller incremental improvements and added more tests. The tests can be run with:
$ ./node_modules/hot-cocoa/bin/testrunner.js
This does three things.
- It tests that all of the sample statements in parseTests.js are correctly parsed by both the recursive descent parser and the CYK parser.
- It test that all of the sample statements in tests/compile.js are correctly compiled and run.
- For each .out file in the examples directory it compiles the associated .hcl file to a .js file and compares the output to the .out file.
I've also fixed the repl to use the Node.js repl library:
$ ./bin/hcl
hcl> (+ 1 2)
3
options I should add to the hcl CLI
- run with node right away
- compile for the browser
- version
- help
man page?
March 12
Sam telling me what happened this week:
- Implemented a better version of scope in variable instantiation.
April 2
"Most of the language features are complete."
Sam described a possible extension to (require 'file.js')
which is typical in nodejs, which he would
use also to handle code aimed at a browser by including
the file. I argued that (include 'file.js') would be
cleaner.
We also talked about whether underscore.js (or some of its
functions) should be included by default in hcl .
Probably, since they're tasty function things like
map.
April 16
I've made a fairly detailed outline for my language design paper. I was hoping we could discuss it in tutorial today and see if there were any topics you thought I should cover that aren't in there or that are in there and I could leave out.