Commit | Line | Data |
---|---|---|
60154d24 JM |
1 | # mal - Make a Lisp |
2 | ||
bcddc3e4 JM |
3 | ## Description |
4 | ||
b76aa73b JM |
5 | Mal is an Clojure inspired Lisp interpreter. |
6 | ||
9d42904e | 7 | Mal is implemented in 22 different languages: |
bcddc3e4 | 8 | |
edc3b064 | 9 | * Bash shell |
bcddc3e4 | 10 | * C |
edc3b064 JM |
11 | * C# |
12 | * Clojure | |
891c3f3b | 13 | * CoffeeScript |
1771ab50 | 14 | * Go |
b76aa73b | 15 | * Haskell |
bcddc3e4 | 16 | * Java |
d32f9b87 | 17 | * Javascript ([Online Demo](http://kanaka.github.io/mal)) |
9d42904e | 18 | * Lua |
bcddc3e4 JM |
19 | * GNU Make |
20 | * mal itself | |
6301e0b6 | 21 | * Perl |
edc3b064 JM |
22 | * PHP |
23 | * Postscript | |
24 | * Python | |
9b3362e8 | 25 | * R |
f5223195 | 26 | * Racket |
8adb0827 | 27 | * Ruby |
abdd56eb | 28 | * Rust |
821930db | 29 | * Scala |
ee7cd585 | 30 | * Visual Basic.NET |
bcddc3e4 JM |
31 | |
32 | ||
0f4ca9d1 | 33 | Mal is a [learning tool](process/guide.md). Each implementation of mal is separated into 11 |
b76aa73b JM |
34 | incremental, self-contained (and testable) steps that demonstrate core |
35 | concepts of Lisp. The last step is capable of self-hosting (running | |
36 | the mal implemenation of mal). | |
bcddc3e4 JM |
37 | |
38 | The mal (make a lisp) steps are: | |
39 | ||
0f4ca9d1 JM |
40 | * [step0_repl](process/guide.md#step0) |
41 | * [step1_read_print](process/guide.md#step1) | |
42 | * [step2_eval](process/guide.md#step2) | |
43 | * [step3_env](process/guide.md#step3) | |
44 | * [step4_if_fn_do](process/guide.md#step4) | |
45 | * [step5_tco](process/guide.md#step5) | |
46 | * [step6_file](process/guide.md#step6) | |
47 | * [step7_quote](process/guide.md#step7) | |
48 | * [step8_macros](process/guide.md#step8) | |
49 | * [step9_try](process/guide.md#step9) | |
50 | * [stepA_interop](process/guide.md#stepA) | |
bcddc3e4 JM |
51 | |
52 | ||
53 | Mal was presented publicly for the first time in a lightning talk at | |
54 | Clojure West 2014 (unfortunately there is no video). See | |
55 | mal/clojurewest2014.mal for the presentation that was given at the | |
56 | conference (yes the presentation is a mal program). | |
60154d24 JM |
57 | |
58 | ## Building/running implementations | |
59 | ||
bcddc3e4 | 60 | ### Bash 4 |
60154d24 JM |
61 | |
62 | ``` | |
63 | cd bash | |
64 | bash stepX_YYY.sh | |
65 | ``` | |
66 | ||
bcddc3e4 | 67 | ### C |
60154d24 | 68 | |
01c97316 JM |
69 | The C implementation of mal requires the following libraries (lib and |
70 | header packages): glib, libffi6 and either the libedit or GNU readline library. | |
54c75382 | 71 | |
60154d24 JM |
72 | ``` |
73 | cd c | |
74 | make | |
75 | ./stepX_YYY | |
76 | ``` | |
77 | ||
9b1563a3 | 78 | ### C# ### |
edc3b064 JM |
79 | |
80 | The C# implementation of mal has been tested on Linux using the Mono | |
81 | C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are | |
82 | required to build and run the C# implementation. | |
83 | ||
84 | ``` | |
85 | cd cs | |
86 | make | |
ee7cd585 | 87 | mono ./stepX_YYY.exe |
edc3b064 JM |
88 | ``` |
89 | ||
90 | ||
bcddc3e4 | 91 | ### Clojure |
60154d24 JM |
92 | |
93 | ``` | |
94 | cd clojure | |
95 | lein with-profile +stepX trampoline run | |
96 | ``` | |
97 | ||
891c3f3b JM |
98 | ### CoffeeScript |
99 | ||
100 | ``` | |
101 | sudo npm install -g coffee-script | |
102 | cd coffee | |
103 | coffee ./stepX_YYY | |
104 | ``` | |
105 | ||
1771ab50 JM |
106 | ### Go |
107 | ||
fd888612 JM |
108 | You Go implementation of mal requires that go is installed on on the |
109 | path. The implementation has been tested with Go 1.3.1. | |
110 | ||
1771ab50 JM |
111 | ``` |
112 | cd go | |
113 | make | |
114 | ./stepX_YYY | |
115 | ``` | |
116 | ||
117 | ||
b76aa73b JM |
118 | ### Haskell |
119 | ||
2988d38e | 120 | Install the Haskell compiler (ghc/ghci), the Haskell platform and |
5400d4bf JM |
121 | either the editline package (BSD) or the readline package (GPL). On |
122 | Ubuntu these packages are: ghc, haskell-platform, | |
123 | libghc-readline-dev/libghc-editline-dev | |
b76aa73b JM |
124 | |
125 | ``` | |
126 | cd haskell | |
127 | make | |
128 | ./stepX_YYY | |
129 | ``` | |
130 | ||
131 | ||
bcddc3e4 | 132 | ### Java 1.7 |
60154d24 | 133 | |
01c97316 JM |
134 | The Java implementation of mal requires maven2 to build. |
135 | ||
60154d24 JM |
136 | ``` |
137 | cd java | |
138 | mvn compile | |
139 | mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY | |
140 | # OR | |
141 | mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS" | |
142 | ``` | |
143 | ||
bcddc3e4 | 144 | ### Javascript/Node |
60154d24 JM |
145 | |
146 | ``` | |
147 | cd js | |
54c75382 | 148 | npm update |
60154d24 JM |
149 | node stepX_YYY.js |
150 | ``` | |
151 | ||
9d42904e JM |
152 | ### Lua |
153 | ||
154 | Running the Lua implementations of mal requires lua 5.1 or later, | |
155 | luarocks and the lua-rex-pcre library installed. | |
156 | ||
157 | ``` | |
158 | cd lua | |
159 | make # to build and link linenoise.so | |
160 | ./stepX_YYY.lua | |
161 | ``` | |
162 | ||
bcddc3e4 | 163 | ### Mal |
60154d24 JM |
164 | |
165 | Running the mal implementation of mal involves running stepA of one of | |
166 | the other implementations and passing the mal step to run as a command | |
5d446bd8 | 167 | line argument. |
60154d24 JM |
168 | |
169 | ``` | |
170 | cd IMPL | |
171 | IMPL_STEPA_CMD ../mal/stepX_YYY.mal | |
172 | ||
173 | ``` | |
174 | ||
bcddc3e4 | 175 | ### GNU Make 3.81 |
60154d24 JM |
176 | |
177 | ``` | |
178 | cd make | |
179 | make -f stepX_YYY.mk | |
180 | ``` | |
181 | ||
9b1563a3 | 182 | ### Perl 5.8 |
9e5b2151 JM |
183 | |
184 | For readline line editing support, install Term::ReadLine::Perl or | |
185 | Term::ReadLine::Gnu from CPAN. | |
186 | ||
187 | ``` | |
188 | cd perl | |
189 | perl stepX_YYY.pl | |
190 | ``` | |
191 | ||
192 | ||
bcddc3e4 | 193 | ### PHP 5.3 |
60154d24 | 194 | |
01c97316 JM |
195 | The PHP implementation of mal requires the php command line interface |
196 | to run. | |
197 | ||
60154d24 JM |
198 | ``` |
199 | cd php | |
200 | php stepX_YYY.php | |
201 | ``` | |
202 | ||
bcddc3e4 | 203 | ### Postscript Level 2/3 |
60154d24 | 204 | |
01c97316 JM |
205 | The Postscript implementation of mal requires ghostscript to run. It |
206 | has been tested with ghostscript 9.10. | |
207 | ||
60154d24 JM |
208 | ``` |
209 | cd ps | |
fa64b741 | 210 | gs -q -dNODISPLAY -I./ stepX_YYY.ps |
60154d24 JM |
211 | ``` |
212 | ||
a05f7822 | 213 | ### Python (2 or 3) |
60154d24 JM |
214 | |
215 | ``` | |
216 | cd python | |
217 | python stepX_YYY.py | |
218 | ``` | |
8adb0827 | 219 | |
9b3362e8 JM |
220 | ### R |
221 | ||
222 | The R implementation of mal requires R (r-base-core) to run. | |
223 | ||
224 | ``` | |
225 | cd r | |
9d42904e | 226 | make libs # to download and build rdyncall |
f5223195 JM |
227 | Rscript stepX_YYY.r |
228 | ``` | |
229 | ||
230 | ### Racket (5.3) | |
231 | ||
232 | The Racket implementation of mal requires the Racket | |
233 | compiler/interpreter to run. | |
234 | ||
235 | ``` | |
236 | cd racket | |
237 | ./stepX_YYY.rb | |
9b3362e8 JM |
238 | ``` |
239 | ||
8adb0827 JM |
240 | ### Ruby (1.8) |
241 | ||
242 | ``` | |
243 | cd ruby | |
244 | ruby stepX_YYY.rb | |
245 | ``` | |
592eb5cf | 246 | |
abdd56eb JM |
247 | ### Rust (0.13) |
248 | ||
249 | The rust implementation of mal requires the rust compiler and build | |
250 | tool (cargo) to build. | |
251 | ||
252 | ``` | |
253 | cd rust | |
111dbaf1 JM |
254 | # Need patched pcre lib (should be temporary) |
255 | git clone https://github.com/kanaka/rust-pcre cadencemarseille-pcre | |
abdd56eb JM |
256 | cargo build |
257 | ./target/stepX_YYY | |
258 | ``` | |
259 | ||
821930db JM |
260 | ### Scala ### |
261 | ||
262 | Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html): | |
263 | ||
264 | ``` | |
265 | cd scala | |
266 | sbt 'run-main stepX_YYY' | |
267 | # OR | |
268 | sbt compile | |
269 | scala -classpath target/scala*/classes stepX_YYY | |
270 | ``` | |
271 | ||
ee7cd585 JM |
272 | ### Visual Basic.NET ### |
273 | ||
274 | The VB.NET implementation of mal has been tested on Linux using the Mono | |
275 | VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are | |
276 | required to build and run the VB.NET implementation. | |
277 | ||
278 | ``` | |
279 | cd vb | |
280 | make | |
281 | mono ./stepX_YYY.exe | |
282 | ``` | |
283 | ||
284 | ||
285 | ||
592eb5cf JM |
286 | ## Running tests |
287 | ||
a816262a | 288 | The are nearly 500 generic Mal tests (for all implementations) in the |
592eb5cf JM |
289 | `tests/` directory. Each step has a corresponding test file containing |
290 | tests specific to that step. The `runtest.py` test harness uses | |
291 | pexpect to launch a Mal step implementation and then feeds the tests | |
292 | one at a time to the implementation and compares the output/return | |
293 | value to the expected output/return value. | |
294 | ||
295 | To simplify the process of running tests, a top level Makefile is | |
296 | provided with convenient test targets. | |
297 | ||
298 | * To run all the tests across all implementations (be prepared to wait): | |
299 | ||
300 | ``` | |
301 | make test | |
302 | ``` | |
303 | ||
304 | * To run all tests against a single implementation: | |
305 | ||
306 | ``` | |
307 | make test^IMPL | |
308 | ||
309 | # e.g. | |
310 | make test^clojure | |
311 | make test^js | |
312 | ``` | |
313 | ||
314 | * To run tests for a single step against all implementations: | |
315 | ||
316 | ``` | |
317 | make test^stepX | |
318 | ||
319 | # e.g. | |
320 | make test^step2 | |
321 | make test^step7 | |
322 | ``` | |
323 | ||
324 | * To run a specifc step against a single implementation: | |
325 | ||
326 | ``` | |
327 | make test^IMPL^stepX | |
328 | ||
329 | # e.g | |
330 | make test^ruby^step3 | |
331 | make test^ps^step4 | |
332 | ``` | |
fd888612 JM |
333 | |
334 | ## License | |
335 | ||
336 | Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public | |
337 | License 2.0). See LICENSE.txt for more details. | |
338 |