-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
integrate with source maps for good line numbers #13
Comments
@wycats brought up an interesting idea, to get better line numbers short of the complexity of sourcemaps you can just get smarter about inserting spaces and newlines. For example, a macro that emits a function with line breaks:
could be expanded to:
This should be easy to do in the expander, just set the Going the other way (macro invocation is longer than emitted JS) should be pretty simple:
could use
Unfortunately, ASI complicates the process a bit.
If we naively expand this while collapsing lines:
we get the wrong result. So the line collapsing needs to be grammar aware (I'm guessing minifiers do the same thing) and insert semicolons at the appropriate points:
But we still have a problem: So maybe we can tag each token emitted from a macro with a "potential" collapse line number and do proper semicolon insertion after all macros have been expanded and we have the "real" grammar information? |
is there any more thought on this? |
This is happening very soon. I'm expecting sourcemaps to land in the next few weeks. |
Initial work checked in with 6c4c40c. Still rough atm but |
mkSyntax no longer puts 0s for line information if a context is not provided. Line info gets set correctly after a macro expansion anyway.
Should be mostly working with 4f15b50. |
Any documentation on that? Sadly, the wiki entry is still red. :/ |
Use the |
It might "just work" with the latest version of escodegen but I have a feeling expansion introduced some problems.
The text was updated successfully, but these errors were encountered: