Skip to content

JML4 HowTo Build the Parser

John L. Singleton edited this page Dec 2, 2015 · 1 revision

Prerequisites:

  • Ensure that the JikesPG is installed. IMPORTANT NOTE: you need a special version of the JikesPG; instructions are given here
  • If javac and java are not on your path, then ensure that you have the following environment variables defined (either they should be set by default in your shell or you need to define them when invoking make):
    • JAVAC: path to a java compiler (if different from "javac").
    • JAVA: path to a java VM launcher (if different "java").

Building the parser within Eclipse is what is easiest:

  • Ensure that the following projects are checked out and open:
    • jml4-utils
    • org.eclipse.jdt.core
  • Create an External Tool "Program" entry as, e.g.:
    • Name: make UpdateParserFiles step1.
    • Location: /bin/make (this will also work under Cygwin -- if Eclipse was launched from Cygwin).
    • Working Directory: ${workspace_loc:/jml4-utils/tools/UpdateParserFiles}.
    • Arguments: (inclusion of the definition of ECLIPSE_HOME is optional; you can also consider adding definitions for JAVA and JAVAC; -s runs make in silent mode, remove this option if you want all commands to be printed as they are executed)
      • Under Windows use: -s ECLIPSE_HOME="${eclipse_home}" ECLIPSE_WORKSPACE="${workspace_loc}" TARGET=step1 fix-eclipse-var-paths
      • Under any other OS: -s ECLIPSE_HOME="${eclipse_home}" ECLIPSE_WORKSPACE="${workspace_loc}" step1
      • Note: If the JikesPG is not on your PATH, then you can add the following argument to the invocation of make: JIKESPG=<path-to-jikespc>.
    • Select the Refresh tab:
      • Check "Refresh resources upon completion".
      • Select "Specific resources" and then click on "Specify resources ..." and check "jml4-utils" and "org.eclipse.jdt.core".
    • Save the External Tool configuration (by clicking apply).
  • Duplicate the previous External Tool configuration and
    • Replace all occurrences of step1 by step2.
    • Save the configuration.
    • Exit the External Tools dialog.
  • Run the two external tools that you have justed defined, starting with step1 then step2.

Notes:

  • Effort has been put into making this process idempotent: i.e., if you run it on the grammar file of the JDT Core CVS head you will generated files that are identical to those in the JDT Core CVS.
  • The generic Eclipse notes on this topic are here: JDT Core / HowTo: Generate the Parser.
  • If you do not want to add the JikesPG to your path, you can add an argument to the external tool program configuration: JIKESPG=<path-to-jikespg>.
  • Use defs-info to see the values of ECLIPSE_HOME and ECLIPSE_WORKSPACE.

If you want to build the parser from the command line then:

  • Ensure that you have the following environment variables defined
    • ECLIPSE_WORKSPACE
  • Ensure that the JikesPG executable is on your build path. (If it is not, that is ok; you will still have the option of providing the path to make -- see below.)
  • Run jml4-utils/tools/UpdateParserFiles/Makefile on target step1.
    • This will cause new parser *.java files to be created.
  • Refresh your org.eclipse.jdt.core project

so that is sees the updated files and compiles them. (It is IMPORTANT that you do this step because the next ones depend on it.)

  • Address any compilation errors.
  • Run jml4-utils/tools/UpdateParserFiles/Makefile on target step2.
    • This will cause new parser table resource files and a property file to be created.
  • Refresh your org.eclipse.jdt.core project.
  • You might want to run jml4-utils/tools/UpdateParserFiles/Makefile on target clean once you are done.
Clone this wiki locally