Skip to content
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

WastLexer: log lexing errors directly #2013

Merged
merged 3 commits into from
Oct 3, 2022
Merged

WastLexer: log lexing errors directly #2013

merged 3 commits into from
Oct 3, 2022

Conversation

keithw
Copy link
Member

@keithw keithw commented Oct 3, 2022

Currently, the WastLexer logs errors by calling the Error method on a passed-in WastParser. This makes it inconvenient to log an error in contexts where no WastParser was available (e.g. from WastLexer::NoTrailingReservedChars()). This is newly an issue because of the tokenization change in WebAssembly/spec#1499.

This PR changes/simplifies things so a WastLexer receives an Errors* parameter on construction, just like a WastParser does. That lets the WastLexer log errors directly. This also disentangles the lexer and parser a bit (i.e. we no longer need to include wast-parser.h in wast-lexer.cc).

This also updates the tokens.txt test to include an extra error message that we had been losing.

(Edit: And also a corresponding change to the Emscripten helper and the JavaScript wrappers that call it... I'm not sure this JavaScript code gets tested in the CI, but I did build locally and test the demos, and it appears to work and reflect the changes.)

@keithw keithw requested a review from sbc100 October 3, 2022 18:45
@keithw keithw mentioned this pull request Oct 3, 2022
@keithw keithw requested a review from binji October 3, 2022 20:05
@keithw keithw force-pushed the lexer-error-handling branch from 3ab7222 to d068e75 Compare October 3, 2022 20:17
Copy link
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to include docs/demo/wabt.js in this change?

@keithw
Copy link
Member Author

keithw commented Oct 3, 2022

Did you mean to include docs/demo/wabt.js in this change?

I did... it seemed a good time to do it, since we're changing the signatures of some functions that get called between the post JS and the C++ Emscripten helpers. But I'm definitely not an expert in JavaScript or the JS parts of WABT...

@keithw keithw merged commit 1adcc91 into main Oct 3, 2022
@keithw keithw deleted the lexer-error-handling branch October 3, 2022 21:18
matthias-blume pushed a commit to matthias-blume/wabt that referenced this pull request Dec 16, 2022
* Log all lexing errors in WastLexer (rather than via parser)

* Update docs/demo/libwabt.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants