-
Notifications
You must be signed in to change notification settings - Fork 65
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
allow await #504
Comments
I thought I needed this once or twice, but have gotten around it by pre-processing the async class, post-processing a generated AST, or parsing once, processing, and parsing again. The most interesting cases are those where the text the grammar would accept is modified by the results of an async call that uses information parsed from the input. There will have to be an option that affects code generation. Discussion:
This is going to be a good amount of work to get correct. A compelling use case would help increase its priority. |
@hildjj I think we can add a async mode. In async mode, all parser methods are async, even without 'await' keyword. And 'await' only allowed in this mode. |
async as a 'mode' is a bad idea imo. It might seem like easy win, but it will cost the development in the longer run. |
Not really, because what works in async also works in sync. |
Unfortunately, no, because even sync code in async function will produce a Promise that resolves in next microtask. If you need truly sync code (for example, in |
I don't think this should be done on peggy side. Grammar is not a programming language, actions are best described in a separate file (and even better if it's in a typed language), and only valid reasons to use actions in peggy is to clean up AST and, maybe, write some prototype in its online playground. Asynchronous code is certainly something that should be done well outside the grammar. |
@reverofevil makes a compelling point. I'm going to mark this as "not planned" for the moment. Good arguments could persuade me otherwise, but this seems like a LOT of work and breakage for not enough benefit at the moment. |
get this error :
await
could be allowed inside expression body function.The text was updated successfully, but these errors were encountered: