chore(grit): implement node-like compilers + fixes #3253
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I feel I will have a pretty major announcement coming up soon, since this PR brings the bindings in a state where an actual Grit query can execute and match against an arbitrary JS snippet. The pattern execution appears to return a correct
true
orfalse
result indicating whether the query matched or not. Also, if I change the pattern in the quick test to use the rewrite operator (=>
) I can see the Grit engine produce anEffect
, which is a data structure describing the rewrite that should take place, so this is really exciting.What does not work yet, is extracting the ranges where matches are found when I don't use a rewrite operator. I suppose I could also try modifying the query to include an empty rewrite and extract the range from the
Effect
, but maybe @morgante knows an easier trick to do what I want. In any case, I'll keep that for a follow-up PR.Of course there are plenty of other things that still need polishing/implementation before this could be considered ready for real adoption, but now that we are reaching the point where the engine is finally doing actual useful stuff, it may also become easier for other contributors to help out since many of the improvements that still need to be made should be doable independently. I'll write up a bit more about the things to do when I send out the announcement.
Test Plan
Updated the quick test, but I'll start adding more systematic tests soon.