Skip to content

Commit

Permalink
Logo implementation
Browse files Browse the repository at this point in the history
Tested on UCBLogo 6.0 with some minor tweaks (for performance and adding
a `timems` function).  The tweaks are performed during Docker image
creation (see Dockerfile).

Tests of step 5 are skipped because UCBLogo is too slow.

Interop is available via `(logo-eval "logo code to run")`.

The `examples` directory contains a Mal example of drawing a tree using
turtle graphics.
  • Loading branch information
dubek committed Jun 17, 2016
1 parent 67962ba commit 4eb88ef
Show file tree
Hide file tree
Showing 25 changed files with 2,576 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -32,6 +32,7 @@ matrix:
- {env: IMPL=js, services: [docker]}
- {env: IMPL=julia, services: [docker]}
- {env: IMPL=kotlin, services: [docker]}
- {env: IMPL=logo, services: [docker]}
- {env: IMPL=lua, services: [docker]}
- {env: IMPL=make, services: [docker]}
- {env: IMPL=mal BUILD_IMPL=js NO_PERF=1, services: [docker]}
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -61,6 +61,7 @@ DEFERRABLE=1
OPTIONAL=1

# Extra implementation specific options to pass to runtest.py
logo_TEST_OPTS = --start-timeout 60 --test-timeout 120
mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
miniMAL_TEST_OPTS = --start-timeout 60 --test-timeout 120
plpgsql_TEST_OPTS = --start-timeout 60 --test-timeout 180
Expand All @@ -78,7 +79,7 @@ DOCKERIZE =

IMPLS = ada awk bash c d clojure coffee cpp crystal cs erlang elisp \
elixir es6 factor forth fsharp go groovy guile haskell haxe \
io java julia js kotlin lua make mal ocaml matlab miniMAL \
io java julia js kotlin logo lua make mal ocaml matlab miniMAL \
nim objc objpascal perl perl6 php plpgsql plsql ps python r \
racket rpython ruby rust scala swift swift3 tcl vb vhdl vimscript

Expand Down Expand Up @@ -107,6 +108,7 @@ regress_step9 = $(regress_step8) step9
regress_stepA = $(regress_step9) stepA

test_EXCLUDES += test^bash^step5 # never completes at 10,000
test_EXCLUDES += test^logo^step5 # too slow for 10,000
test_EXCLUDES += test^make^step5 # no TCO capability (iteration or recursion)
test_EXCLUDES += test^mal^step5 # host impl dependent
test_EXCLUDES += test^matlab^step5 # never completes at 10,000
Expand Down
14 changes: 13 additions & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@

Mal is a Clojure inspired Lisp interpreter.

Mal is implemented in 55 languages:
Mal is implemented in 56 languages:

* Ada
* GNU awk
Expand Down Expand Up @@ -35,6 +35,7 @@ Mal is implemented in 55 languages:
* JavaScript ([Online Demo](http://kanaka.github.io/mal))
* Julia
* Kotlin
* Logo
* Lua
* GNU Make
* mal itself
Expand Down Expand Up @@ -448,6 +449,17 @@ make
java -jar stepX_YYY.jar
```

### Logo

*The Logo implementation was created by [Dov Murik](https://github.com/dubek)*

The Logo implementation of mal has been tested with UCBLogo 6.0.

```
cd logo
logo stepX_YYY.lg
```

### Lua

Running the Lua implementation of mal requires lua 5.1 or later,
Expand Down
49 changes: 49 additions & 0 deletions logo/Dockerfile
@@ -0,0 +1,49 @@
FROM ubuntu:vivid
MAINTAINER Joel Martin <github@martintribe.org>

##########################################################
# General requirements for testing or common across many
# implementations
##########################################################

RUN apt-get -y update

# Required for running tests
RUN apt-get -y install make python

# Some typical implementation and test requirements
RUN apt-get -y install curl libreadline-dev libedit-dev

RUN mkdir -p /mal
WORKDIR /mal

##########################################################
# Specific implementation requirements
##########################################################

# Install g++ for any C/C++ based implementations
RUN apt-get -y install g++

# Install UCBLogo 6.0:
# * Fix the makefile to build correctly
# * Tweat GC settings to improve performance (it's still very slow)
# * Add the timems function implemented in C
RUN apt-get -y install libx11-dev \
&& cd /tmp \
&& curl -O -J -L http://www.cs.berkeley.edu/~bh/downloads/ucblogo.tar.gz \
&& tar xf ucblogo.tar.gz \
&& cd /tmp/ucblogo-6.0 \
&& rm -rf csls/CVS \
&& ./configure \
&& sed -i -e 's/svnversion/echo 206/' -e 's/^\s*(cd docs/#\0/' makefile \
&& echo "all: everything" >> makefile \
&& sed -i -e 's/^#define *SEG_SIZE *16000 /#define SEG_SIZE 6400000 /' logo.h \
&& sed -i -e 's/^#define GCMAX 16000$/#define GCMAX 16000000/' mem.c \
&& echo "extern NODE *ltimems(NODE *);" >> globals.h \
&& echo "NODE *ltimems(NODE *args) { struct timeval tv; gettimeofday(&tv, NULL); return(make_floatnode(((FLONUM)tv.tv_sec) * 1000.0 + (tv.tv_usec / 1000))); }" >> coms.c \
&& sed -i -e 's/^\(.*lthrow.*\)$/\1 {"timems", 0, 0, 0, PREFIX_PRIORITY, ltimems},/' init.c \
&& make install \
&& cd /tmp \
&& rm -rf /tmp/ucblogo.tar.gz /tmp/ucblogo-6.0

ENV HOME /mal
28 changes: 28 additions & 0 deletions logo/Makefile
@@ -0,0 +1,28 @@
SOURCES_BASE = readline.lg types.lg reader.lg printer.lg
SOURCES_LISP = env.lg core.lg stepA_mal.lg
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

.PHONY: all dist clean stats stats-lisp

all:
@true

dist: mal.lg mal

mal.lg: $(SOURCES)
cat $+ | grep -v "^load " > $@

mal: mal.lg
echo "#!/usr/bin/env logo" > $@
cat $< >> $@
chmod +x $@

clean:
rm -f mal.lg mal

stats: $(SOURCES)
@wc $^
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*\"|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
stats-lisp: $(SOURCES_LISP)
@wc $^
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*\"|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"

0 comments on commit 4eb88ef

Please sign in to comment.