-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat/mini parse 2 alpha #62
base: feat/mini-parse-rework
Are you sure you want to change the base?
Conversation
For tracking spans, I can think of a few different options
What does not work
|
I'm picking the option where If it still ends up being slow, I can try that option:
|
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)
span
combinator, 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.or
parsers assert that their children must be capable of backtracking. Otherwise they'd be useless children.ImportGrammar.ts
_run
method 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.229
towgsl-linker LOC/sec: 123.075
.The unit tests are failing, and that's fine.