switch to uglify.JS parser #5

Open
maxtaco opened this Issue Jul 18, 2011 · 9 comments

Projects

None yet

4 participants

@maxtaco
Owner

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.

@maxtaco maxtaco was assigned Jul 18, 2011
@maxtaco
Owner

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.
@wadey

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)
@maxtaco
Owner

Thanks for the note --- atop which file?

@wadey

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");
@keeganpoppen

+1 on using the uglify.JS parser, or equivalent-- having random semicolon-related compiler issues and it's driving me batty! :)

@maxtaco
Owner

Really sorry about that, are there certain cases in particular that come up a lot that I can try to engineer around?

@keeganpoppen
@xaptronic

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

@xaptronic

Hacked my way around the immediate problem https://gist.github.com/1270453 which was not being able to do obj.default();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment