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

Comment parsing and porting to other languages #251

Open
mcmikecreations opened this issue Dec 18, 2023 · 2 comments
Open

Comment parsing and porting to other languages #251

mcmikecreations opened this issue Dec 18, 2023 · 2 comments

Comments

@mcmikecreations
Copy link

Hi! My team is making a scripting frontend for our database at TUM and we were looking for different language parsers. The codebase is in C++, but I skimmed through meriyah and it should be feasible to rewrite in C++. The question is, we require single- and multi-line comments for type annotations and metadata. Is there a simple way to achieve it in this parser, at least JSDoc-style comments?

@3cp
Copy link
Member

3cp commented Dec 18, 2023

It will be difficult.
The comments in meriyah are not parsed as normal flow of tokens (ESTree spec didn't define comment as a node). There is onComment option (or callback) but it's difficult to know surrounding JS tokens of that comment. There is also some known bugs for onComment.

Speaking about C++ JS parsers, the Chrome V8 and Safari JavaScriptCore are all native C++ parsers, and they are in much better quality than meriyah. You may have a better chance there.

@aralroca
Copy link

Is it possible to add comments to the Meriyah AST? I am interested to put the @__PURE__ in some function calls

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

No branches or pull requests

3 participants