diff 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
line wrap: on
line diff
--- a/editor.js	Wed Mar 21 23:17:49 2012 -0700
+++ b/editor.js	Thu Mar 22 22:52:36 2012 -0700
@@ -1,15 +1,56 @@
 
 
-onReady(function() {
-	each(qall('li'), function (idx,el) {
-		el.onclick = function (event) {
-			q('#src').innerHTML += el.innerHTML;
-		};
+object.prototype.toHTML = function(node) {
+	var el = newEl('div', {
+		className: 'object',
+		innerHTML: '#'
+	});
+	node.appendChild(el);
+	for (var i in this.messages) {
+		this.messages[i].toHTML(el);
+	}
+};
+
+lambda.prototype.toHTML = function(node) {
+	var el = newEl('div', {
+		className: 'lambda',
+		textContent: this.args.join(' ')
+	});
+	node.appendChild(el);
+};
+
+assignment.prototype.toHTML = function(node) {
+	var base = newEl('div', {
+		className: 'assignment'
+	});
+	var varName = newEl('span', {
+		textContent: this.symbol.name + ' <-'
 	});
-	q('#ops_button').onclick = function (event) {
-		addClass(this.parentNode.parentNode, 'showops');
-	};
-	q('#builtin_button').onclick = function (event) {
-		removeClass(this.parentNode.parentNode, 'showops');
-	};
-});
+	base.appendChild(varName);
+	node.appendChild(base);
+	this.expression.toHTML(base);
+};
+
+intlit.prototype.toHTML = function(node) {
+	node.appendChild('span', {
+		className: 'integer',
+		textContent: node.val
+	});
+};
+
+floatlit.prototype.toHTML = function(node) {
+	node.appendChild('span', {
+		className: 'float',
+		textContent: node.val
+	});
+};
+
+strlit.prototype.toHTML = function(node) {
+	node.appendChild('span', {
+		className: 'string',
+		textContent: node.val
+	});
+};
+
+funcall.prototype.toHTML = function(node) {
+};