tamejs
tamejs copied to clipboard
switch to uglify.JS parser
This will solve a lot of the issues with the current parser, like bad error messages and also uneven support for statements not terminated with semi-colons.
Thoughts:
- Do a pre-processing run that rewrites twait --> function __twait (), so that way it will compile as actual javascript?
- Need to find a good way to pick off
this
since it's not a grammar feature as exposed to the AST walker API.
Another thing broken in the current parser: "use strict";
at the top of the file. It results in this confusing compilation error message:
tamejs/lib/parser.js:133
var lst = $$[$0-1].concat ($$[$0]);
^
TypeError: Object #<Node> has no method 'concat'
at Object.anonymous (tamejs/lib/parser.js:133:22)
at Object.parse (tamejs/lib/parser.js:428:40)
at Engine.parse (tamejs/lib/engine.js:362:19)
at tamejs/lib/main.js:186:9
at tamejs/lib/engine.js:339:6
at [object Object].<anonymous> (fs.js:107:5)
at [object Object].emit (events.js:61:17)
at afterRead (fs.js:878:12)
at wrapper (fs.js:245:17)
Thanks for the note --- atop which file?
I just tried to compile a .tjs
file with "use strict";
at the top. Example:
"use strict";
await {
setTimeout(defer(var e, a), 100);
}
console.log("done");
+1 on using the uglify.JS parser, or equivalent-- having random semicolon-related compiler issues and it's driving me batty! :)
Really sorry about that, are there certain cases in particular that come up a lot that I can try to engineer around?
the one that probably gets me the most is semicolons on lines inside 1-liner anonymous functions, but TBH I just switched over to writing semicolons just to avoid the issue. :)
-keegan
On Friday, August 5, 2011 at 5:49 AM, maxtaco wrote:
Really sorry about that, are there certain cases in particular that come up a lot that I can try to engineer around?
Reply to this email directly or view it on GitHub: https://github.com/maxtaco/tamejs/issues/5#issuecomment-1735052
There are also issues with semi colons inside regular expressions.. i.e.
var img_data = req.body.data.match(/^data:image/png;base64,(.+)/);
had to become
var img_data = req.body.data.match('^data:image/png;base64,(.+)');
to compile and I haven't yet worked around the issue where when using the optimist option parser library, calls to .default cause a parse error.. https://gist.github.com/1270412
Hacked my way around the immediate problem https://gist.github.com/1270453 which was not being able to do obj.default();