Open Beakerboy opened 1 year ago
We're doing some preprocessing steps and I don't remember off the top of my head whether we actually parse exported Form components. There is basically multiple different coexisting gestalts of VBA code, not all of which we target (i.e. we have a separate grammar for dealing with preprocessor directives and we parse both exported as well as 'code pane' code in Rubberduck).
@MDoerner probably has smarter things to say about this than me :)
We actually only parse the form headers in order not to fail on them. Afterwards, we ignore that part of the parse tree.
The current grammar's rules around forms are purely based on examples I have seen as there does not seem to be a specification anywhere.
If you want, you can open a PR for the changes. However, if this too much hassle for you, I could also incorporate the changes and see whether our tests still pass.
if this too much hassle for you
Not at all. I was planning on doing that, but thought I’d start the conversation here beforehand. There is a separate Visual Basic 6 grammar that seems to have the changes I was planning on making. Is that to be expected?
Oh, now I realize that you referred to the VBA grammar on the Antlr repo. I think we provided that at some point. However, our grammar at https://github.com/rubberduck-vba/Rubberduck/blob/next/Rubberduck.Parsing/Grammar/VBAParser.g4 has evolved since.
Two bugs in there were actually only fixed last month.
Nice! I didn’t notice a separate grammar within this repository. Should the latest copy be sent over to the ANTLR group? I noticed there were some recent changes over there to fix bugs with line continuation and line numbering.
By the way, our grammar assumes that precompiler directives are already taken care of. To do that we first parse with our precompiler parser https://github.com/rubberduck-vba/Rubberduck/blob/next/Rubberduck.Parsing/Preprocessing/VBAConditionalCompilationParser.g4, evaluate which code is dead and then set the corresponding tokens to hidden before reusing the token stream for the actual parse.
Hm, one could see whether one can merge enhancements in.
I’m just dealing with Linting raw VBA code that is exported from Excel without Rubberduck, so I don’t think the precompiler directives will come into play.
I just published a github action to lint VBA code as part of a CI / CD process. I also created a github organization called VBA-actions, so if any of you have any actions you would like to publish separately from the Rubberduck project, let me know and I can add you to the org.
I’m using ANTLR to parse VBA files and see Rubberduck cited on the most recent version of the grammer file.
When exporting a Form object from Excel VBA, the header looks like this:
This file fails to parse on three places:
I have an updated grammer file that I was hoping to get some feedback on. Let me know if there is a reason the main file should not be updated with my changes.
I’ve:
i Imagine the “real” changes will need to be more nuanced than I’ve made it. For example
’5.00’ | (DOUBLELITERAL WS CLASS)
STRINGLITERAL COLON DIGIT DIGIT DIGIT DIGIT
be considered a separate literal type?