Mercurial > repos > tabletprog
diff tpc.js @ 36:3b0503a67165
Add scripts for building programs via C using d8 rather than a browser
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 10 Jul 2012 19:22:19 -0700 |
parents | |
children | 27a2167663dd |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tpc.js Tue Jul 10 19:22:19 2012 -0700 @@ -0,0 +1,22 @@ +var module = {exports: {}}; +var PEG; + +if (arguments.length < 1) { + print('usage: d8 tpc.js -- filename'); + os.exit(); +} else { + compileFile(arguments[0]); +} + +function compileFile(filename) +{ + var text = read(filename); + load('peg.js'); + PEG = module.exports; + load('parser.js'); + load('compiler.js'); + load('cbackend.js'); + var parsed = parser.parse(text); + var c = parsed.toCModule(); + print(c); +}