--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
+
+
+ <title>Top Down Operator Precedence</title>
+ <style>
+th {background-color: thistle; border: black solid 1px; text-align: left;
+ padding-left: 10px; padding-right: 10px; vertical-align: top;}
+td {background-color: white; border: black solid 1pt; padding-left: 10px;
+ padding-right: 10px; vertical-align: top;}
+table {width: 90%; border: 0px; cellpadding: 0px;}
+ </style>
+</head><body bgcolor="linen">
+<h1>Top Down Operator Precedence</h1>
+
+<p><a href="http://www.crockford.com/">Douglas Crockford</a></p>
+
+<p>2007-08-05</p>
+
+<h2>Demonstration</h2>
+<p>The text that follows is the parse tree that the parser generated by
+ parsing itself. </p>
+<textarea id="INPUT" style="border: 2px solid black; color: black; font-family: monospace; height: 3in; overflow: auto; padding: 0.5em; width: 100%;"></textarea>
+<input id="PARSE" value="parse" type="button">
+<noscript><p>You may not see it because you have JavaScript turned off. Uffff!</p></noscript>
+<script src="tokens.js"></script>
+<script src="parse.js"></script>
+<script src="lambda2.js"></script>
+<script src="json2.js"></script>
+<pre id="OUTPUT">
+</pre>
+<script>
+/*jslint evil: true */
+
+/*members create, error, message, name, prototype, stringify, toSource,
+ toString, write
+*/
+
+/*global JSON, make_parse, parse, source, tree */
+
+// Make a new object that inherits members from an existing object.
+
+if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ function F() {}
+ F.prototype = o;
+ return new F();
+ };
+}
+
+// Transform a token object into an exception object and throw it.
+
+Object.prototype.error = function (message, t) {
+ t = t || this;
+ t.name = "SyntaxError";
+ t.message = message;
+ throw t;
+};
+
+
+(function () {
+ var parse = make_parse();
+
+ function go(source) {
+ var string, tree;
+ try {
+ tree = parse(source);
+// string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
+// string = JSON.stringify(tree.handler(), ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
+ string = tree.handler().to_string();
+ } catch (e) {
+ string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
+ 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
+ }
+ document.getElementById('OUTPUT').innerHTML = string
+ .replace(/&/g, '&')
+ .replace(/[<]/g, '<');
+ }
+
+// go("var make_parse = " + (make_parse.toSource ?
+// make_parse.toSource() : make_parse.toString()) + ";");
+
+ document.getElementById('PARSE').onclick = function (e) {
+ go(document.getElementById('INPUT').value);
+ };
+}());
+
+</script>
+
+</body></html>