How do i set up javacc in intellij IDEA
Asked Answered
R

3

10

I searched through the plugin repo and downloaded the javacc plugin.

Now that I have the plugin how do I use it in IntelliJ.

My project looks like this .

enter image description here

Rademacher answered 8/4, 2015 at 21:16 Comment(1)
did you find any thing ??Ctenoid
P
0

Another approach is to embed JavaCC task into Idea gradle project (code snippet based on kotlin dsl):

buildscript {
    dependencies {
        classpath("net.java.dev.javacc", "javacc", "7.0.10")
    }
}

sourceSets["main"].java.srcDir("src/main/javacc")

...
...
...

task("assembleJavacc") {
    val outDir = "$projectDir/src/main/javacc/your/gen/package/dir"
    doLast {
        arrayOf(
            "-JDK_VERSION=1.8", "-OUTPUT_DIRECTORY=$outDir",
            "$projectDir/src/main/resources/ParserDefinition.jj"
        ).also {
            JJTree().main(it).takeIf { rs -> rs == 0 }
                ?: throw RuntimeException("jjtree error: ${it.contentToString()}")
        }
        arrayOf("-OUTPUT_DIRECTORY=$outDir", "$outDir/ParserDefinition.jj.jj")
            .also {
                Main.mainProgram(it).takeIf { rs -> rs == 0 }
                    ?: throw RuntimeException("javacc error: ${it.contentToString()}")
            }
    }
}
Paramour answered 6/4, 2021 at 22:40 Comment(0)
U
-1

Responding to this a bit late, but maybe it can help someone. As far as I know the JavaCC Plugin for the IntelliJ IDEA only supports editing of files, not the generation of the Java files. For this you'll have to use the command line. Download JavaCC and add the bin directory to your path. The bin directory should look something like this:

javacc      jjdoc       jjrun       jjtree.bat
javacc.bat  jjdoc.bat   jjtree      lib

where lib should contain your javaccX.jar file. Now you can generate your Java files from the command line:

javacc ./my-grammar-file.jj
Unlay answered 31/1, 2018 at 10:49 Comment(2)
there s no "bin" directoryWilsey
@VeryGudJavaDev The name of /bin directory has apparently changed to /scripts. The procedure should still be the same though.Unlay
B
-4

In this case, select "Assignment3", right-click, choose "Open Module Settings", make sure "Assignment3" is selected in the center column. In the right column, click the "Dependencies" tab and you will see a drop-down that is labeled "Module SDK:" This is where you specify the JDK location. Choose "New..." and if using a plug-in, choose "IntelliJ Platform Plugin SDK". The pop-up will allow you to navigate to the location of the plug-in Java SDK you downloaded; be sure to choose the parent directory of the "bin", "jre", "lib", etc. directories, not the actual "bin" directory itself. If however you had downloaded a JDK instead of a plug-in (I tend to favor external JDKs myself), you'd choose "JDK" instead, navigate to the JDK's parent-of-"bin",-etc. directory and choose that one. Then click "OK" to make the selection. Then click "Apply" and you will have set the JDK for your project module.

Breathing answered 27/8, 2015 at 21:45 Comment(1)
I answered this in 2015. It's 2018 and we are a number of versions of IntelliJ ahead of whatever was current back then. So re the above dirs, I can safely say they are out of date.Breathing

© 2022 - 2024 — McMap. All rights reserved.