forked from mvdan/sh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
_js: add a non-blocking wrapper of Interactive
JS only has a single thread, meaning that if the interactive parser blocks on a call, the only way to run any other code in the meantime is to run it as part of the "read" call. This is understandably clunky, as the API was designed for concurrent languages. However, with about twenty lines of code we can offer an API that never blocks to JS, which is more usable for real programs. It does re-parse chunks of incomplete statements, but those shouldn't get very large. Adding a non-blocking Interactive variant to the original parser would be too much of a refactor, since it's a recursive descent parser. It can't be stopped and resumed, as the parse state is in the call stack.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters