annotate testparse.js @ 31:668f533e5284

Add initial version of C backend
author Mike Pavone <pavone@retrodev.com>
date Sat, 07 Jul 2012 16:48:36 -0700
parents 04ae32e91598
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 onReady(function() {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 q('#parse').onclick = function() {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 var text = q('textarea').value;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 try {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 var parsed = parser.parse(text);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 q('pre').innerHTML = text + "\n\n" + JSON.stringify(parsed);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 console.log(parsed);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 } catch(e) {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 q('#tojs').onclick = function() {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 var text = q('textarea').value;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 //try {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 var parsed = parser.parse(text);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 var js = parsed.toJSModule();
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 q('pre').innerHTML = js;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 console.log(parsed);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 /*} catch(e) {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 }*/
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 }
31
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
24 q('#toc').onclick = function() {
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
25 var text = q('textarea').value;
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
26 //try {
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
27 var parsed = parser.parse(text);
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
28 var c = parsed.toCModule();
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
29 setText(q('pre'), c);
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
30 console.log(parsed);
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
31 /*} catch(e) {
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
32 q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
33 }*/
668f533e5284 Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
34 }
8
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 q('#run').onclick = function() {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 var text = q('textarea').value;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 //try {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 var parsed = parser.parse(text);
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 var js = parsed.toJSModule();
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 mainModule = eval(js)();
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 q('pre').innerHTML = mainModule.main();
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 /*} catch(e) {
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 q('pre').innerHTML = e.message + '\nLine: ' + e.line + '\nCol: ' + e.column;
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 }*/
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 }
04ae32e91598 Move compiler and test page related code out of parser.js
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 });