Permalink
Browse files

New web build.

  • Loading branch information...
1 parent bb734b0 commit cc66e0960c209a16118fa63a788756d23fd41716 @zaach committed Apr 25, 2010
Showing with 429 additions and 3 deletions.
  1. +15 −3 Jakefile
  2. +55 −0 web/index.html
  3. +359 −0 web/lambdacalc.js
View
@@ -3,17 +3,29 @@
var FILE = require("file"),
ENV = require("system").env,
OS = require("os"),
- jake = require("jake");
+ jake = require("jake"),
+ bundler = require("cjs-bundler");
var cwd = FILE.path(FILE.cwd());
-jake.task("build", ["build_commonjs"]);
+jake.task("build", ["build:commonjs"]);
-jake.task("build_commonjs", function () {
+jake.task("build:commonjs", function () {
OS.system(['jison', 'src/lambdacalc.jison', 'src/lambdacalc.jisonlex']);
OS.system(['mv', 'lambdacalc.js', 'lib/lambdacalc/parser.js']);
});
jake.task("test", function () {
OS.system(['narwhal', 'tests/all-tests.js']);
});
+
+var path = FILE.path(FILE.cwd());
+
+jake.task("build:web", function() {
+ var script = bundler.bundle([
+ { id : "lambdacalc", path : path.join("lib", "lambdacalc.js") },
+ { id : "lambdacalc/parser", path : path.join("lib", "lambdacalc", "parser.js") }
+ ]);
+
+ FILE.write("web/lambdacalc.js", "var require = (function() {\n" + script + ";\nreturn require;\n})();");
+});
View
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Lambda Calculus Evaluator</title>
+ <style>
+ body {
+ font-family: Helvetica, sans-serif;
+ background-color: #e8eef6;
+ color: #234;
+ text-shadow: 0px 1px 0px white;
+ }
+ textarea {
+ font-size: 1.2em;
+ border: 1px inset #fff;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ }
+ </style>
+</head>
+<body onload="main()">
+
+ <h1>Lambda Calculus Evaluator</h1>
+ <p>Call-by-value edition.</p>
+
+ <textarea cols="80" rows="20" id="source">(^x.x x) ^y.y</textarea>
+ <p>
+ <button id="run">Run</button>
+ </p>
+
+ <pre id="result"></pre>
+
+ <p>By <a href="http://zaa.ch">Zach Carter</a>, 2010. MIT Licensed.</p>
+
+ <a href="http://github.com/zaach/lambdacalc"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
+
+ <script src="lambdacalc.js"></script>
+ <script>
+ function main () {
+ var lambdacalc = require("lambdacalc");
+ console.log(lambdacalc);
+
+ document.getElementById("run").onclick = function () {
+ try {
+ var result = lambdacalc.eval(document.getElementById("source").value);
+ document.getElementById("result").innerHTML = result;
+ } catch(e) {
+ document.getElementById("result").innerHTML = e;
+ }
+ };
+
+ }
+ </script>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit cc66e09

Please sign in to comment.