Add test for pre compiler issues with parenthesis #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds direct unit tests for the ANTLR VBA preprocessor parser, allowing us to catch syntax errors and undesired implicit tokens without relying on the VS Code diagnostics layer. It introduces a new test script in
package.json, a dedicated test file for parser validation; and new test cases to verify correct parsing of function calls.I originally discovered an issue with the preprocessor when dealing with this line:
Sometimes, depending on if there was an extra space somewhere on this line or not, the precompilation would break and cause issues with conditional compilation. I've managed to simplify the problem to be about matching the last closing parenthesis on the line without it being caught by the implicit
T__1orT__2token. See ParsingParenthesis.bas for a minimal reproducible example with the following line:y = Format( "Test '<'")Which leads to a syntax error that can be observed using
Debug ANTLR4 Pre grammar:Or by using the new test script this PR introduces:
I have the fix below ready, but I'd like to see the CI run without the fix first to demonstrate the issue.
Basically, simply having an explicit definition for
LPARENandRPARENand including them as areservedWordsolves the above issue: