Feat/mini parse 2 alpha#62
Draft
stefnotch wants to merge 7 commits into
Draft
Conversation
Contributor
Author
|
For tracking spans, I can think of a few different options
What does not work
|
Contributor
Author
|
I'm picking the option where If it still ends up being slow, I can try that option:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
tl;dr: I finally got to try out all my mini-parse ideas. 🎉 I am now wondering which of these are worth keeping, and which ones are not.
I tried writing a mini-parse library which
token(kind: Kind, value: string)spancombinator, but I'm not convinced that that design is good.seq2(tryToken("keyword", "import"), token("symbol", ";"))has the semantics "only the first thing of the sequence parser can backtrack", so only that part will get aif (result == null) return null;check.orparsers assert that their children must be capable of backtracking. Otherwise they'd be useless children.ImportGrammar.ts_runmethod calledparseNext. It's intended that users can write parsers in an alternative style, seeParser2.test.ts. This lets us hand-write parsers and parsing logic for hot paths of the code.To try it out, I then wrote a parser combinator which calls the new implementation. And then I rewrote the imports grammar to use the new implementation.
Benchmarks are on Discord, but the rough results are that the perf could go from
wgsl-linker LOC/sec: 33.229towgsl-linker LOC/sec: 123.075.The unit tests are failing, and that's fine.