Reader

4 views
Skip to first unread message

Kevin Downey

unread,
Oct 30, 2009, 10:54:09 PM10/30/09
to Clojure Dev
I have written a Clojure reader in Clojure. The reader passes what
tests there are and can be used to build Clojure.

quickstart:
git clone git://github.com/hiredman/clojure.git
git checkout readerIII
ant -buildfile build.rdr.xml


1. Implementation:

a. fairly direct port of LispReader

b. The reader is implemented as a single function, because
functions are compiled to classes.

c. I use (several layers of) letfn to break the function up into
sub-functions that map to the parts of LispReader. using letfn in this
way lets me avoid namespace loading and var deref'ing.

d. When compiled the name of the class that the read function is
compiled to is written to reader.properties.

e. clojure.reader

2. Changes to Clojure:

a. LispReaderFn added to LispReader.java. This allows for calling
LispReader/read via and IFn interface so usage of my reader and
LispReader becomes identical.

b. RT.java's static block now tries to read the classname for the
reader from reader.properties (on the classpath) and failing that
falls back to LispReaderFn. The reader IFn is then instantiated and
bound to clojure.core/READER.

c. Added RT/read which is a convenience static method that takes
care of clojure.core/READER invoking for java code. All calls to
LispReader/read in java code are replaced with calls to this method.

d. ReaderException (static inner class) moved into RT.java, I
think all the clojure specific exceptions could be replaced with a
single exception that implements IMeta and then exception typing could
use type tags.

3. Changes to the build system:

a. I have included build.rdr.xml which should have all the
functionality of build.xml

b. build.rdr.xml builds all java parts, builds the clojure parts,
builds the reader, deletes the clojure parts, and rebuilds the clojure
parts using the reader.

c. ant -buildfile build.rdr.xml

http://github.com/hiredman/clojure/tree/readerIII

Kevin Downey

unread,
Oct 30, 2009, 11:03:44 PM10/30/09
to Clojure Dev
whoops, quickstart should be

git clone readerIII git://github.com/hiredman/clojure.git
cd clojure
git pull origin readerIII
ant -buildfile build.rdr.xml
and optionally:
ant -buildfile build.rdr.xml test

--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

Kevin Downey

unread,
Oct 30, 2009, 11:05:14 PM10/30/09
to Clojure Dev
this is all works, I swear!

git clone git://github.com/hiredman/clojure.git


cd clojure
git pull origin readerIII
ant -buildfile build.rdr.xml
and optionally:
ant -buildfile build.rdr.xml test

Reply all
Reply to author
Forward
0 new messages