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
Rewriter needs to account for "dead code" #2938
Comments
One possibility would be, as soon as we have the token stream for a module (well, after it's given to the parser for processing, I suppose), to get its rewriter and immediately replace the |
I'll take a crack at getting line numbers in the grammar. Can you provide different use cases I would need to account for? |
Might we be able to solve the problem with the preprocessing directives by sending the parts to ignore to another channel instead of replacing them? Obviously, that would need some external variables in the lexer. |
@MDoerner that's absolutely worth considering! ...except, wouldn't it mean we need embed the preprocessing logic into the lexer itself? |
@Hosch250 - When I was looking at adding line numbers and labels to the grammar, I determined that it shouldn't be horribly difficult but it will probably require a bit of work. I think the key is to add something like an Re preprocessor directives, would it work if we just sent that token stream to a different ANTLR channel? |
@retailcoder I think we can put them on another channel outside the lexer. The |
As of recently, all module-rewriting operations are carried through a
TokenStreamRewriter
. That's a huge leap forward and greatly improves undo-ability and overall module-rewriting accuracy, however there's a problem that wasn't addressed:TokenStreamRewriter
works off the lexer token stream, and that stream is "cleansed" so that the parser can work around a number of limitations:WS
tokensWS
tokensTherefore, piping all module changes to TSR's has also introduced a nasty side-effect: we're turning the user's modules into how Rubberduck sees them. And that doesn't include line numbers and "dead" precompiler code paths.
We can't have all precompiler code paths in the token streams, and despite all our efforts anything that tries to get line numbers picked up by a parser rule breaks the grammar.
We can't release anything until we've found a solution to this problem - how do we go about it?
The text was updated successfully, but these errors were encountered: