Skip to content

Create Incremental Parser.md#82019

Merged
CyrusNajmabadi merged 5 commits into
mainfrom
CyrusNajmabadi-patch-1
Jan 15, 2026
Merged

Create Incremental Parser.md#82019
CyrusNajmabadi merged 5 commits into
mainfrom
CyrusNajmabadi-patch-1

Conversation

@CyrusNajmabadi

Copy link
Copy Markdown
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 15, 2026 01:36
Comment thread docs/compilers/Design/Incremental Parser.md Outdated
Comment thread docs/compilers/Design/Incremental Parser.md Outdated
CyrusNajmabadi and others added 2 commits January 15, 2026 12:13
Co-authored-by: Joseph Musser <me@jnm2.com>
Co-authored-by: Joseph Musser <me@jnm2.com>
In most cases, reparsing M1 will produce the same skipped tokens as before. However, it's possible
that the edit in M2 could affect M1's parse due to lookahead. For example, if M1's error was caused
by something that the edit in M2 somehow resolved, the reparse of M1 might produce a different
(possibly valid) tree.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if there are parse errors that result in neither skipped nor missing tokens, these constraints don't apply and the subtree with the error will be reused? But can't it also be affected by lookahead? (In fact, cannot any parsing, even successful one, be affected by lookahead like this?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll adjust. If it has any diagnostics, it is not reused. It's just that skipped/missing are the major causes of diagnostics. I've written previously that they should be the only causes in the parser. But we're not currently there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll adjust. If it has any diagnostics, it is not reused. It's just that skipped/missing are the major causes of diagnostics. I've written previously that they should be the only causes in the parser. But we're not currently there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. And for non-erroneous parsing, I guess the incremental parsing logic just assumes that the underlying parsing logic won't be affected by lookahead across the reusable blocks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess the incremental parsing logic just assumes that the underlying parsing logic won't be affected by lookahead across the reusable blocks?

Correct. We know that this is true by construction (currently). And we have no language constructs we're interested in that would change this.

Generated files (source generators, T4 templates, etc.) are not a concern for incremental parsing
performance. Users don't edit generated files in real time, so we won't be receiving incremental
edits for them. Full parses of generated files are acceptable since they happen infrequently
(typically only when the generator runs).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some probably do (or will) run on every keystroke, like razor, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But as mentioned, razor does not produce edits. So we will full parse. If we wanted incremental there we'd need razor to change how it generates the new docs.

This may be an area that needs attention in the future. But it's currently out of scope with all the rest of the things razor needs to address first :-)

@CyrusNajmabadi CyrusNajmabadi merged commit 2deb0b1 into main Jan 15, 2026
3 of 4 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the CyrusNajmabadi-patch-1 branch January 15, 2026 16:02
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Jan 15, 2026
@davidwengier davidwengier modified the milestones: Next, 18.4 Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants