view testparse.js @ 19:132c7756860e

Use populateSymbols to generate symbol tables during compilation rather than populating them as we go. This change allows us to refer to symbols defined later in the input stream and also gives the symbol table logic a single home that can be used both by the compiler and editor.
author Mike Pavone <pavone@retrodev.com>
date Sun, 25 Mar 2012 16:11:19 -0700
parents 04ae32e91598
children 668f533e5284
line wrap: on
line source


onReady(function() {
	q('#parse').onclick = function() {
		var text = q('textarea').value;
		try {
			var parsed = parser.parse(text);
			q('pre').innerHTML = text + "\n\n" + JSON.stringify(parsed);
			console.log(parsed);
		} catch(e) {
			q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
		}
	}
	q('#tojs').onclick = function() {
		var text = q('textarea').value;
		//try {
			var parsed = parser.parse(text);
			var js = parsed.toJSModule();
			q('pre').innerHTML = js;
			console.log(parsed);
		/*} catch(e) {
			q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
		}*/
	}
	q('#run').onclick = function() {
		var text = q('textarea').value;
		//try {
			var parsed = parser.parse(text);
			var js = parsed.toJSModule();
			mainModule = eval(js)();
			q('pre').innerHTML = mainModule.main();
		/*} catch(e) {
			q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
		}*/
	}
});