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

VBA Conditional Compilation Grammar #4137

Merged
merged 4 commits into from
Jun 17, 2024
Merged

Conversation

Beakerboy
Copy link
Contributor

VBA includes a precompiler of sorts, with its own grammar. The existing vba6 grammar tries to shoehorn it in with the main language, but there are situations where a VBA file with CC statements is not valid VBA until after the precompiler is run.
For example:

#If WIN64 Then
Function Foo(bar, Optional baz = 1)
#Else
Function Foo(bar, Optional baz = 2)
#End If
End Function

This new grammar powers a precompiler which can turn this example into valid VBA given a set of environment variables.

Beakerboy and others added 2 commits June 10, 2024 10:06
@Beakerboy
Copy link
Contributor Author

I see that there is a failure in only one of the build matricies. I’m more than happy to fix this if someone can tell me what it means.

@kaby76
Copy link
Contributor

kaby76 commented Jun 10, 2024

The problem is that there are symbol conflicts: EMPTY, WIN16, WIN32, WIN64. In your grammar .g4 file, append an underscore (_) to the end of these symbols, then check-in and retest.

Please enter a bug in https://github.com/antlr/antlr4/issues saying that for the Cpp target, EMPTY, WIN16, WIN32, WIN64 are known conflicts, like because there are #defines somewhere for Visual C++. The implementation for resolving symbol conflict is not reliable, and there is a long lack time between finding a symbol conflict and then releasing a new version of the Antlr Tool to take care of the issue--if there are anymore Antlr4 releases! There should be an option to append or prepend a string to all names in the generated files, so we don't need to keep adjusting the table for "known" symbol conflicts, or manually adjusting the grammar to workaround the problem.

Readd target when regression is fixed.
@Beakerboy
Copy link
Contributor Author

Beakerboy commented Jun 10, 2024

I’ve removed that target. I can re-add it in a a few days when I add the VBA 7.1 grammar.

* Update vba_cc.g4

* Update desc.xml
@Beakerboy
Copy link
Contributor Author

Beakerboy commented Jun 10, 2024

Renamed tokens after the ninja edit and re-added the CPP target. Good to go.

@Beakerboy
Copy link
Contributor Author

In case you were waiting for this..I also filed the big report as requested:
antlr/antlr4#4641

@teverett
Copy link
Member

@Beakerboy thanks!

@teverett teverett added the vba label Jun 17, 2024
@teverett teverett merged commit 73e94ae into antlr:master Jun 17, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants