comparison editor.js @ 14:85fb6ba15bc6

Start turning AST into HTML in editor
author Mike Pavone <pavone@retrodev.com>
date Thu, 22 Mar 2012 22:52:36 -0700
parents 3d1b8e96f5dc
children a5ef5af3df0f
comparison
equal deleted inserted replaced
13:e69f5ab0a453 14:85fb6ba15bc6
1 1
2 2
3 onReady(function() { 3 object.prototype.toHTML = function(node) {
4 each(qall('li'), function (idx,el) { 4 var el = newEl('div', {
5 el.onclick = function (event) { 5 className: 'object',
6 q('#src').innerHTML += el.innerHTML; 6 innerHTML: '#'
7 };
8 }); 7 });
9 q('#ops_button').onclick = function (event) { 8 node.appendChild(el);
10 addClass(this.parentNode.parentNode, 'showops'); 9 for (var i in this.messages) {
11 }; 10 this.messages[i].toHTML(el);
12 q('#builtin_button').onclick = function (event) { 11 }
13 removeClass(this.parentNode.parentNode, 'showops'); 12 };
14 }; 13
15 }); 14 lambda.prototype.toHTML = function(node) {
15 var el = newEl('div', {
16 className: 'lambda',
17 textContent: this.args.join(' ')
18 });
19 node.appendChild(el);
20 };
21
22 assignment.prototype.toHTML = function(node) {
23 var base = newEl('div', {
24 className: 'assignment'
25 });
26 var varName = newEl('span', {
27 textContent: this.symbol.name + ' <-'
28 });
29 base.appendChild(varName);
30 node.appendChild(base);
31 this.expression.toHTML(base);
32 };
33
34 intlit.prototype.toHTML = function(node) {
35 node.appendChild('span', {
36 className: 'integer',
37 textContent: node.val
38 });
39 };
40
41 floatlit.prototype.toHTML = function(node) {
42 node.appendChild('span', {
43 className: 'float',
44 textContent: node.val
45 });
46 };
47
48 strlit.prototype.toHTML = function(node) {
49 node.appendChild('span', {
50 className: 'string',
51 textContent: node.val
52 });
53 };
54
55 funcall.prototype.toHTML = function(node) {
56 };