1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
6 <title>Top Down Operator Precedence</title>
8 th {background-color: thistle; border: black solid 1px; text-align: left;
9 padding-left: 10px; padding-right: 10px; vertical-align: top;}
10 td {background-color: white; border: black solid 1pt; padding-left: 10px;
11 padding-right: 10px; vertical-align: top;}
12 table {width: 90%; border: 0px; cellpadding: 0px;}
14 </head><body bgcolor="linen">
15 <h1>Top Down Operator Precedence</h1>
17 <p><a href="http://www.crockford.com/">Douglas Crockford</a></p>
21 <h2>Demonstration</h2>
22 <p>The text that follows is the parse tree that the parser generated by
24 <textarea id="INPUT" style="border: 2px solid black; color: black; font-family: monospace; height: 3in; overflow: auto; padding: 0.5em; width: 100%;"></textarea>
25 <input id="PARSE" value="parse" type="button">
26 <noscript><p>You may not see it because you have JavaScript turned off. Uffff!</p></noscript>
27 <script src="tokens.js"></script>
28 <script src="parse.js"></script>
29 <script src="lambda2.js"></script>
30 <script src="json2.js"></script>
34 /*jslint evil: true */
36 /*members create, error, message, name, prototype, stringify, toSource,
40 /*global JSON, make_parse, parse, source, tree */
42 // Make a new object that inherits members from an existing object.
44 if (typeof Object.create !== 'function') {
45 Object.create = function (o) {
52 // Transform a token object into an exception object and throw it.
54 Object.prototype.error = function (message, t) {
56 t.name = "SyntaxError";
63 var parse = make_parse();
69 // string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
70 // string = JSON.stringify(tree.handler(), ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
71 string = tree.handler().to_string();
73 string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
74 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
76 document.getElementById('OUTPUT').innerHTML = string
77 .replace(/&/g, '&')
78 .replace(/[<]/g, '<');
81 // go("var make_parse = " + (make_parse.toSource ?
82 // make_parse.toSource() : make_parse.toString()) + ";");
84 document.getElementById('PARSE').onclick = function (e) {
85 go(document.getElementById('INPUT').value);