fstirlitz / luaparse

A Lua parser written in JavaScript
https://fstirlitz.github.io/luaparse/
MIT License
459 stars 91 forks source link

Improve DX #33

Closed oxyc closed 4 years ago

oxyc commented 8 years ago

Considering adding this as v3. Seems more logical to set the humanly readable line numbers in the cli instead of hardcoding into the message.

mathiasbynens commented 8 years ago

Is this cross-browser-compatible?

oxyc commented 8 years ago

The only real change is that context data are now solely attached to the error object, and can't be gleaned from the message string. I've never researched but I assume thrown objects work with properties in all legacy browsers?

The main reason for this change is that I've noticed all libraries that use luaparse need to manipulate the error object to be usable, ie https://github.com/rameshvarun/linter-luaparse/blob/master/lib/linter.js#L17:L20.

If we go this way, it would also be nice to get at least the plumbing for tolerant error handling before bumping the major version.

mathiasbynens commented 8 years ago

I was asking because error objects have historically had different names and formats for properties/values in different engines. Not sure what the current status is on name, line, column, and message.

oxyc commented 8 years ago

Ah, thanks for the heads up! I'll make sure to look into it.

fstirlitz commented 7 years ago

@oxyc, are you planning to merge this at some point? May want to rebase it with my changes to the testing framework.

oxyc commented 7 years ago

@fstirlitz thanks for the heads up, I'll do that. As this is a breaking change which doesn't really fix any bugs or add much, I'm in no hurry to get it merged. I was thinking if there's ever some larger feature (eg error tolerance), it could be added in the same version bump.

Lately seems I've been neglecting the project though, thanks for keeping it going!

fstirlitz commented 7 years ago

As for breaking changes, I've already added the Lua versioning switch and interpretation of escape sequences in string literals. What do you think about the issue I mentioned in a comment in readUnicodeEscapeSequence(), by the way?

And with regards to this specific change, I'd also change the error object so that it's no longer a SyntaxError. After all, SyntaxError is meant for errors in JavaScript code. How do you distinguish a syntax error in luaparse from an error in the input fed to it?

fstirlitz commented 6 years ago

@oxyc: w.r.t. SyntaxError, please take a look at 8536fdfafc7b1823d16e3012ad0ba26dbc795d5b.

fstirlitz commented 4 years ago

This PR has stalled, and I think I'll be addressing problems raised here in a different way. Closing.