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 .
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 .
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()}")
}
}
}
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
/bin
directory has apparently changed to /scripts
. The procedure should still be the same though. –
Unlay 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.
© 2022 - 2024 — McMap. All rights reserved.