CpS 450 Language Translation Systems

Software Setup

  1. Install Java 21 Development Kit. On Windows, you can do that with the following command:
    winget install EclipseAdoptium.Temurin.21.JDK
    
  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 gradle, and install Gradle for Java.
    • Search for antlr, and install ANTLR4 grammar syntax support. Then, I suggest pressing F1, choosing “Preferences: Open User Settings (JSON)”, and adding the following setting inside the curly brackets:

       "antlr4.generation": {
          "mode": "none"
       }
      

      That will prevent the VSCode ANTLR extension from generating Java code into your project in an inappropriately named .antlr folder.

  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 gradlew executable and execute ./gradlew build install). This command compiles the project and runs the unit test. There should be no errors.

  5. Locate the script build\install\lexer\bin\lexer and use it to run the lexer. Use 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}"
        }
    ]
}