Skip to content
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

Parse a module #21

Open
retailcoder opened this issue Feb 12, 2023 · 2 comments
Open

Parse a module #21

retailcoder opened this issue Feb 12, 2023 · 2 comments
Labels
component: Rubberduck.Client Issue involves RPC client/platform component: Rubberduck.Core Issue involves the Core library component: Server.LSP Issue involves the LSP server process feature: editor shell Issues that relate to the editor shell skill:antlr Issue that involve Antlr grammar and/or parse trees

Comments

@retailcoder
Copy link
Member

retailcoder commented Feb 12, 2023

Wire up and adjust all the necessary RD2 components to produce an ANTLR parse tree for any module loaded in the workspace.

At this stage we only care about getting a parse tree to provide the editor with syntax errors and folding ranges: we need this parse to remain sub-second and as reliably fast as possible for all module under 5K lines of code (half the maximum allowed). Preliminary in-process tests gave excellent sub-second results for all module sizes.

Technically we could also wire up the parse tree inspections/diagnostics, but for performance reasons these will have to run separately from this quick-parse syntactical pass.

@retailcoder retailcoder added skill:antlr Issue that involve Antlr grammar and/or parse trees feature: editor shell Issues that relate to the editor shell component: Server.LSP Issue involves the LSP server process component: Rubberduck.Core Issue involves the Core library component: Rubberduck.Client Issue involves RPC client/platform labels Feb 12, 2023
@Vogel612
Copy link
Member

Note that this implies we need to actually do syntax error recovery. There are two possibilities for that: Either we introduce a SyntaxError rule that matches as few tokens as possible at the last possible alternative in every relevant rule (to scope the errors as small as possible), or we teach the generated ANTLR parser how to recover from the errors.

The first one has the advantage of being somewhat simple in theory and easy to deal with for pretty-printing and resolver passes, the second one is more "spiritually correct" and less likely to accidentally parse syntax errors where there are none (because backtracking with syntax error parser rules is wicked complicated).

@retailcoder
Copy link
Member Author

retailcoder commented Apr 26, 2023

Oh that part was done (started, at least - still need custom syntax error messages for a great UX) during the PoC ☺️
Essentially, Antlr recovers all by itself; in RD2 we just prevent it by throwing as soon as we encounter an error, but if we instead let Antlr do its thing, it's actually super clever and works exactly like we need - coming up with meaningful and appropriate error messages is the hard part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Rubberduck.Client Issue involves RPC client/platform component: Rubberduck.Core Issue involves the Core library component: Server.LSP Issue involves the LSP server process feature: editor shell Issues that relate to the editor shell skill:antlr Issue that involve Antlr grammar and/or parse trees
Projects
None yet
Development

No branches or pull requests

2 participants