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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion vba/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<modules>
<module>vba6</module>
<module>vba_cc</module>
<module>vba_like</module>
</modules>
</project>
</project>
7 changes: 7 additions & 0 deletions vba/vba_cc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Visual Basic Conditional Compilation Grammar for ANTLR4

Derived from the Visual Basic 7.1 language reference

https://msopenspecs.azureedge.net/files/MS-VBAL/%5bMS-VBAL%5d.pdf

The vba_cc grammar can be used against vba files to analyze that portion of the code.
5 changes: 5 additions & 0 deletions vba/vba_cc/desc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../_scripts/desc.xsd">
<antlr-version>^4.10</antlr-version>
<targets>CSharp;Cpp;Dart;Go;Java;JavaScript;Python3;TypeScript</targets>
</desc>
28 changes: 28 additions & 0 deletions vba/vba_cc/examples/cc.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Attribute VB_Name = "CCTEST"
#Const conDebug = 1

#If conDebuge = 1 Then 'Run debug code
Debug.Print "oops"
#Elseif conDebug > 1 Then
Debug.Print "help"
#Else
#If Cdbl(Abs(conDebug)) < (1 Mod 3) Then

foo = 2
#Endif
#End If

Open pth for output as #ff
Print #ff, cont
Close #ff

' The blocks can each be empty.
#if Win64 Then
#Elseif Win32 Then
#Else
#Endif

' The blocks can each be empty.
#if 1 / 2 = .5 Then
foo = 4
#Endif
57 changes: 57 additions & 0 deletions vba/vba_cc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>vba7_1</artifactId>
<packaging>jar</packaging>
<name>VBA 7.1 grammar</name>
<parent>
<groupId>org.antlr.grammars</groupId>
<artifactId>grammarsv4</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr.version}</version>
<configuration>
<sourceDirectory>${basedir}</sourceDirectory>
<includes>
<include>vbaLexer.g4</include>
<include>vbaParser.g4</include>
</includes>
<visitor>true</visitor>
<listener>true</listener>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.khubla.antlr</groupId>
<artifactId>antlr4test-maven-plugin</artifactId>
<version>${antlr4test-maven-plugin.version}</version>
<configuration>
<verbose>false</verbose>
<showTree>false</showTree>
<entryPoint>startRule</entryPoint>
<grammarName>vba_cc</grammarName>
<packageName></packageName>
<exampleFiles>examples/</exampleFiles>
</configuration>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading