Project Summary

Curry Grammar Applet

Submitted By:
Chris Gilmore
July 7th, 2001

 

For this project I am continuing the work of four other students: Hazel Morgan, summer 1997, Vijayasree Krishnaprasad, fall 1997 and Phillip R. Neff, Winter 98, Sushma Kumar, Spring 1998 and Shobha Ranganathan, Winter 99.  These students were responsible for the design of the applet.  The applet can also function as an application if executed from the command line.  For most cases, the applet will be viewed as such through a web page for ease of access.

Design of applet:
    The applet consists of a frame which holds several panels, a button panel and a panel which has a card layout and contains all of the diagrams.  The diagrams are constructed from a grammar file which can be modified to update the applet when the grammar changes (See Modifying the grammar below).

Goals for this project:
    I had several tasks I wanted to get done for this project.  First I wanted to add a start button to button panel so that wherever one is in the diagram path, one can return to the top level of the grammar.  Second I updated the grammar to include modules and their corresponding keywords.  This turned out to be a larger job than I first thought since I ended up having to update a good portion of the grammar so it matched the latest version of the grammar.  Some side effects of updating the grammar were that I had to widen the size of the applet so that several panels would fit in the applet.  I also encoded the size within the applet itself so the applet would also be the right size and give the correct dimensions when queried.  Third I changed the way that regular expressions were displayed so that they were more like the other diagrams.  Originally, regular expression were displayed in one or more lines depending on their length.  This caused differences in both font and font size.  But since the applet was widened for the grammar, I was able to simplify the code which displays the regular expressions.

These tasks went well although some took longer than I originally expected.  Of the three tasks I found the updating the grammar to be the most challenging since it really required that I understood what the grammar meant so I could translate it to the applet's grammar representation.  Changing how the regular expressions were displayed was the next most difficult as the original code was difficult to understand how exactly it worked.

Future Changes:
    There are several changes that could be done to the applet to enhance its usability.  A forward button could be added so that one could go forward through the grammar diagrams.  I would also add a menu system which would allow the user to view the diagrams viewed and also allow the user to jump to a specific diagram chosen from the menu.

    Other than these and perhaps other unknown cosmetic changes, the major foreseeable changes are to the grammar.  Updating the grammar shown by the applet is a several step process.  First there is a file called gr.txt which contains the grammar translated into a XML like language.  The grammar must be updated here first.  The language is relatively simple to understand.  The language consists of tags which are enclosed in parentheses.  The major tags are:
    diagram (which is the first tag for every piece of grammar)
    sequence (which allows several tags to linked together)
    zero-or-more (which creates a path where a tag may be taken and repeated or not)
     terminal (which allows literal strings to be introduced)
    nonterminal (which creates a link to another diagram)
    optional (which is similar to zero-or-more without the possibility of looping)
    loop (which allows a path to be repeated)
    choice (which allows a choice between two paths)

A sample tag looks like this

    (diagram
      (sequence
         (terminal "module")
         (nonterminal ModuleID)
         (loop
           (nonterminal SomeDiagram))))

Once the changes have been made to gr.txt, the Grammar class must be created by using the GrammarConverter program.  This program takes the name of the file containing the grammar (gr.txt) and the name of the java file to be constructed.  In our case we want to use Grammar, which will create the Grammar.java file.  If there are any errors, they will be reported as the Grammar.java file is being created.  Once the Grammar.java is created, it must be compiled.  After compilation, the applet is ready to go.  Currently a jar file is not being used for distribution of the applet but changing this would be trivial.

Conclusion:

    The work I done on the applet helps it usability and it is important that the grammar correctly reflect the current state of the Curry language.  I found the functionality of the applet to be quite stable and had no problems while working with the applet other that my own errors in creating the diagrams for the updating the grammar.