view scripttags.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 37d7f60a8ea1
children 4d87c38404d6
line wrap: on
line source


function compileAndRun(src)
{
	var ast = parser.parse(src);
	var js = ast.toJSModule();
	mainModule = eval(js)();
	mainModule.main();
}

onReady(function() {
	var tags = qall('script[type="text/tabletprog"]');
	for (var i = 0; i < tags.length; ++i) {
		if (tags[i].src) {
			get(tags[i].src, function(req) {
				compileAndRun(req.responseText);
			});
		} else {
			compileAndRun(tags[i].innerHTML);
		}
	}
});