eclipsejavacc

eclipse "Compile with javacc" just does nothing


I haven't used javaCC for several years. Now (year 2024) that I try it again with the lates tools, "Compile with javacc" just does nothing: no *.java files generated, no error messages, just, plain, nothing.

It is possible to call javacc on my (old) *.jj and *.jjt files and I get my *.java files (where eclipse complains later about some errors, very probably to the fact that many things have changed by the time they were working, some 5-15 years ago).

One additional thing to mention is that the standard example file MyNewGrammer.jjt produces (via shell command "javacc MyNewGrammer.jjt") java files where jjtThis is unknown ... straight from the automatically generated jjt).

I also dimly remember that *.jjt was converted to *.jj first, but I see no trace of it now.

What's wrong? Are there currently know issues or common pitfalls?


helper@gg$ javac -version
javac 11.0.24
helper@gg$ javacc -version
7.0.12
helper@gg$ javacc -verbose MyNewGrammar.jjt 
Java Compiler Compiler Version 7.0.12 (Parser Generator)
(type "javacc" with no arguments for help)
Warning: Bad option "-verbose" will be ignored.
Reading from file MyNewGrammar.jjt . . .
File "TokenMgrError.java" is being rebuilt.
File "ParseException.java" is being rebuilt.
File "Token.java" is being rebuilt.
File "SimpleCharStream.java" is being rebuilt.
Parser generated successfully.
helper@gg$ 

The tools I use are those coming with eclipse and what I got from "The Marketplace" searching for JavaCC.

Eclipse tells me it was "JavaCC Eclipse Plug-in Feature" (version 1.6.1):

JavaCC & JTB editor, views, nature and builder which process .jj, .jjt & .jtb files and integrate with Eclipse's incremental build system, for head (and headless) builds. Must be installed for head builds (ie with the UI). Will allow headless builds. Compatible with Eclipse Neon+ (4.6+) and Java 1.8+. Embeds some versions of JavaCC and JTB jars.


Solution

  • OS

    Linux: Ubuntu

    JDK 17

    Please install your own JDK, recommended version: JDK 17.

    Download Eclipse IDE: eclipse-jee-2024-06

    https://www.eclipse.org/downloads/packages/release/2024-06/r

    UNZIP eclipse-jee-2024-06-R-linux-gtk-x86_64.tar.gz

    Run Eclipse

    cd eclipse-jee-2024-06-R-linux-gtk-x86_64/eclipse
    ./eclipse
    

    Config Workspace Directory:

    I use an empty directory WK as the workspace directory.

    /your-path/WK
    

    Install JavaCC Eclipse Plug-in

    Eclipse Marketplace

    003.png

    license agreement

    004.png

    005.png

    006.png

    007.png

    Software Updates

    Create Project

    008.png

    Menu File -> New - Other

    009.png

    Select a wizard

    010.png

    011.png

    Open Associated Perspective ?

    Create New Folder

    012.png

    MyJavaCCExample -> New -> Folder

    013.png

    Add Source Folder

    014.png

    015.png

    016.png

    Source Folder Selection

    017.png

    Config JavaCC

    018.png

    JavaCC -> Javacc options

    019.png

    020.png

    021.png

    JavaCC options change

    Do you want to rebuild the project for options changes to take effect ?

    Delete module-info.java

    022.png

    Create JavaCC jj file

    023.png

    MyJavaCCExample -> src -> New -> File

    024.png

    Create New File

    025.png

    Use Browser Open https://github.com/gammasoft/gammalang/blob/master/calculator.jj

    Please note that the JavaCC Console is executed automatically.

    026.png

    MyJavaCCExample -> outputJavaCC -> (default package)

    Based on the contents of calculator.jj, Calculator.java and other files are automatically generated.

    Run Java Application or Run As (Run Configurations)

    027.png

    MyJavaCCExample -> outputJavaCC -> Calculator.java

    or

    028.png

    MyJavaCCExample -> outputJavaCC -> Calculator.java

    029.png

    Left Tree: Java Application

    Right Part:

    Console

    033.png

    In Console:

    Input: 11 + 22 Then Press Enter Key

    Then show 33.0