Maven generates python code for python3 ANTLR grammar file

I downloaded Python3 grammar file for ANLTR4 https://github.com/antlr/grammars-v4/blob/master/python/python3-py/Python3.g4 and when I run mvn generate-sources in eclipse, the Python3Lexer.java generated file contains some Java and some Python code eg.:

private void NEWLINE_action(RuleContext _localctx, int actionIndex) {
        switch (actionIndex) {
        case 0:

            tempt = Lexer.text.fget(self)
            newLine = re.sub("[^\r\n\f]+", "", tempt)
            spaces = re.sub("[\r\n\f]+", "", tempt)
            la_char = ""
            try:

antlr dependency in pom :

dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <version>4.7.2</version>
            <exclusions>
                <exclusion>
                    <groupId>org.abego.treelayout</groupId>
                    <artifactId>org.abego.treelayout.core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <version>4.7.1</version>
                <executions>
                    <execution>
                        <id>antlr</id>
                        <goals>
                            <goal>antlr4</goal>
                        </goals>
                        <configuration>
                            <listener>false</listener>
                            <visitor>true</visitor>
                            <treatWarningsAsErrors>true</treatWarningsAsErrors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

any suggestions?



Read more here: https://stackoverflow.com/questions/66269504/maven-generates-python-code-for-python3-antlr-grammar-file

Content Attribution

This content was originally published by Joe S at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: