1 <textarea id="INPUT" style="border: 2px solid black; color: black; font-family: monospace; height: 3in; overflow: auto; padding: 0.5em; width: 100%;">
4 let and = \l r. l r false in
7 (and true false yes no)
8 (and false true yes no)
9 (and false false yes no)
12 <input id="PARSE" value="Normalize" type="button">
13 <input id="ETA" type="checkbox">do eta-reductions too
14 <noscript><p>You may not see it because you have JavaScript turned off. Uffff!</p></noscript>
15 <script src="/code/lambda.js"></script>
16 <script src="/code/tokens.js"></script>
17 <script src="/code/parse.js"></script>
18 <script src="/code/json2.js"></script>
22 /*jslint evil: true */
24 /*members create, error, message, name, prototype, stringify, toSource,
28 /*global JSON, make_parse, parse, source, tree */
30 // Make a new object that inherits members from an existing object.
32 if (typeof Object.create !== 'function') {
33 Object.create = function (o) {
40 // Transform a token object into an exception object and throw it.
42 Object.prototype.error = function (message, t) {
44 t.name = "SyntaxError";
51 var parse = make_parse();
54 var string, tree, expr, eta;
57 // string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
58 expr = tree.handler();
59 // string = JSON.stringify(expr, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
60 // string = expr.to_string() + "\n\n~~>\n\n";
62 eta = document.getElementById('ETA').checked;
63 string = string + reduce(expr, eta, false).to_string();
65 string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
66 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
68 document.getElementById('OUTPUT').innerHTML = string
69 .replace(/&/g, '&')
70 .replace(/[<]/g, '<');
73 document.getElementById('PARSE').onclick = function (e) {
74 go(document.getElementById('INPUT').value);