Skip to content

Instantly share code, notes, and snippets.

@GlassGhost
Last active August 29, 2015 14:26
Show Gist options
  • Save GlassGhost/6cba24478d265d9ec30d to your computer and use it in GitHub Desktop.
Save GlassGhost/6cba24478d265d9ec30d to your computer and use it in GitHub Desktop.
Generate LC-min.js Binary Lambda Calculus Interpreter
#!/bin/bash
ISO_8601=`date -u "+%FT%TZ"` #ISO 8601 Script Start UTC Time
utc=`date -u "+%Y.%m.%dT%H.%M.%SZ"` #UTC Time (filename safe)
owd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #Path to THIS script.
# Copyright 2015 Roy Pfund
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#_______________________________________________________________________________
#Creates a minified JS exe for the binary lambda calculator described at
# http://tromp.github.io/cl
#and at
# http://www.ioccc.org/2012/tromp/hint.html
mkdir "$owd/LC"; cd "$owd/LC"
[ ! -f ./compiler-latest.zip ] && echo "Downloading" && \
curl -R -O -L https://dl.google.com/closure-compiler/compiler-latest.zip
[ ! -f ./uni.c ] && echo "Downloading" && \
curl -R -O -L http://tromp.github.io/cl/uni.c
[ ! -f ./compiler.jar ] && echo "Decompressing" && \
unzip compiler-latest.zip compiler.jar
[ ! -f ./LC.js ] && echo "Compiling" && \
emcc -DM=999999 -m32 -std=c99 uni.c -o LC.js
[ ! -f ./LC-min.js ] && echo "Minifying" && \
java -jar compiler.jar --js LC.js --js_output_file LC-min.js
# needs a command to remove the trailing commas on the lines listed from javascript
# for now it works if the user removes them by hand.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment