DemeterF/DemFGen+JavaCC in Eclipse

Set up the JavaCC plug-in for Eclipse

This allows you to run the JavaCC compiler simply by right clicking on a *.jj file and selecting the compile option.
  1. Go to the "Help > Software Updates..." menu option.
  2. Open the "Available Software" tab
  3. Click "Add Site"
  4. Enter this url ( in the location textbox, then click OK
  5. Expand the entry for the new site and its "Uncategorized" subtree.
  6. Check the "JavaCC Feature" checkbox, then click Install
  7. When the installation dialog opens, just click Next
  8. Accept the terms and click Finish
  9. Restart Eclipse

Setup DemeterF (JAR)

Create a project and set it up to use DemeterF. This setup is on a project by project basis, you need to do this for each project you create.
  1. Go to the "File > New > Java Project" menu item.
  2. In Contents section, select Create project from existing source
  3. Click Browse and select the folder you set up in Windows Explorer, click OK
  4. Name the project, then click the Next button
  5. Open the Libraries tab and click "Add External Jars..."
  6. Select the demeterf.jar and the IR2.0.jar (for the Relation class library) and click Open
  7. Click Finish
  8. Once the project opens, select the Run > Run Configurations... menu option
  9. Double click "Java Application" in the left pane to create a new Java Application run configuration
  10. Name the configuration DemFGen
  11. Check the "Include system libraries when searching for Main" checkbox, then click Search
  12. Type "DemFGen" in the search textbox to find the DemFGen class in the default package, click OK
  13. Open the arguments tab and enter your DemFGen arguments. For the example code Prof. Lieberherr usually uses the following:
    --mutable --dgp:ToStr:Print:Display program.beh gen
  14. Click Run (not Apply), and proceed even with the errors
  15. Refresh the project in the package explorer
  16. Expand the gen package (or whatever you named your output folder)
  17. Right click theparser.jj and select "Compile with JavaCC"

Notes on Running The Program

To run your program, right-click on your Main class and select "Run As... > Java Application"

To give the input to your program, open the Console (Alt+Shift+Q C) Type in your input (or copy paste from the provided program.input file) and hit Ctrl+Z to enter an EOF (end-of-file) character. Once you type the EOF, the program will process the input.

You could (should) modify the Main class to create a FileInputStream to read an input file

DemFGen Usage

Here's the DemFGen argument description(s). This is printed whenever you run DemFGen without arguments or if you pass "--help"
                 |          DemFGen Java        |
                 |          10/11/2008          |

 Usage: DemFGen [Options] <CD-File> <BEH-File> <Output-Dir>

 The order/placement of options doesn't matter, but the relative
    order of the manditory ones must be as shown.

 CD-File contains the CD to be generated,
 BEH-File contains the behavior to be used with classes,
 Output-Dir is the directory to place generated files
 Options can be: 
   --help           : Print this usage information.
   --build          : Run JavaCC & JavaC after generating the files
   --lib:FILE       : Implies --build, Create a library named FILE from the
                        compiled/generated code (JAR for Java, DLL for C#)
   --windows        : Use Windows based command launches and CSC to compile
                        C# instead of GMCS. System PATH and CLASSPATH
                        variables need to be set correctly. Works with both
                        '--build' and '--lib'
   --noparse        : Don't generate the parser files or methods
   --mutable        : Generate 'mutable' fields... not final/readonly
   --graph          : Just print a Dot file to StdOut
   --dgp:C1:...:Cn  : A Colon seperated List of Data-generic function
                        classes to be run/generated. Each class must be a
                        subclass of edu.neu.ccs.demeterf.demfgen.dgp.DGPFunc
                        and accessible in the current classpath.
                    * Predefined classes are Print, Display, and ToStr,
                        which generate print(), display(), and toStr()
                        methods respectively. Any/all may be used together.
                    * Each one includes a separate Class that generates the
                        same functionality in a toString method. Those
                        classes are named PrintToString, DisplayToString,
                        and ToString.  Obviously, only one may be used.
                    * See the demfgen.dgp package source for more details.