CpS 450 Language Translation Systems

Software Setup

  1. Install Java 25 Development Kit. On Windows, you can do that with the following command:

    winget install EclipseAdoptium.Temurin.25.JDK
    

    After installing, open a new command prompt and execute java. Verify that you see output similar to the following (the version number is the important thing):

    C:\>java
    openjdk version "25.0.1" 2025-10-21 LTS
    OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8-LTS)
    OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode, sharing)
    

    If you see a different version of Java, you may need to adjust your system PATH environment variable so that the correct version of Java is on your PATH.

  2. I recommend using Visual Studio Code as your editor, because of the excellent support for Java and also the ANTLR plugin that is available for that editor. If you want to try it out, after installing VSCode, install the following plugins using the View > Extensions panel:

    • Search for java, and install Extension Pack for Java.
    • Search for antlr, and install ANTLR4 grammar syntax support.

    Next, configure the antlr plugin to disable its automatic Java code generation feature, which will create .antlr folders that will wreak havoc with your gradle-based Java project. To do that, in VSCode, press F1, choose “Preferences: Open User Settings (JSON)”, and add the following setting inside the curly brackets:

    "antlr4.generation": {
       "mode": "none"
    }
    
  3. Copy the examples/lexer project from the class files (see Resources) to your computer.

  4. In VSCode, choose File > Open Folder, and choose the lexer folder. Use Terminal > New Terminal to access a command prompt. Build the project using gradlew build install (Mac/Linux users must make the gradlew script executable and execute ./gradlew build install). This command compiles the project and runs the unit test. There should be no errors.

    Note: You do not need to install Gradle. The gradlew script automatically downloads and installs Gradle the first time you run it.

  5. Follow the instructions in the lexer/README.md to run the lexer using the sample data file math.txt as a test input file.

  6. You can use VSCode to run the lexer. Choose Run > Open Configurations to open the .vscode/launch.json file that contains run configurations for your project. Copy and paste the example launch.json file below. Then, choose Run > Run without debugging. You should be prompted for command line arguments. Enter math.txt to run the lexer with that file as its argument.

  7. You should be able to make changes to any Java file or the grammar and then run again. VScode will automatically rebuild the project. If it doesn’t for some reason, try deleting the build folder containing the compiled artifacts, then press F1 and enter Java: Rebuild Projects to force a rebuild.

  8. Review the project README.md and use it as a guide to explore the project directory structure. Locate the various components we discussed in class and review their contents.

At this point, you are ready to begin work on Phase 1.

Figure 1: VSCode launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "java",
            "name": "Main",
            "request": "launch",
            "mainClass": "cps450.Main",
            "args": "${command:SpecifyProgramArgs}"
        }
    ]
}