Programming Assignment 3 (due midnight 03/05/14)

Penalty for late submission: 10% less credit/day.

Implement, document (i.e. provide specifications), and test all your code. Make sure all your code is thoroughly tested and runs on tux.

  1. (30 Points) Write Prolog code answering the query of FCS problem 14.3.1 and proving the facts formulated in FCS problem 14.9.2.
  2. (10 Points) Lab 5 - Introduction to Parser Generators.
  3. (60 Points) Create a Parser Generator for Regular Expressions.

    Write a parser for regular expressions using Python with the parser generator PLY. Your parser will take a regular expression as input. It will output a DOT file with the NDFA that accepts the regular expression. (more on DOT files below)

    Input Format
    Your parser should except regular expressions built up from:

    The precedence of these operators should be: closure highest, concatenation next highest and union lowest. The binary operators for union and concatenation should be left associative. You should model your grammar after the mathematic grammar from Lab 5. (Hint: The precedence of the math operators was exponent highest, multiplication next highest, and addition lowest.)

    Here are some examples:

    Note that the comments are not part of the actual input. Nor are you responsible for parsing comments.

    Your program will read from stdin; there will be one expression per line.

    Output Format
    Your output should be a DOT file with the NDFA for the regular expression. We recommend Graphviz for viewing your dot files. On tux you can convert DOT files to images using the dot program. For example, you can convert to 0.gif by entering:
    dot -Tgif -o0.gif
    You should create a DOT file for each line of input. The first regular expression should be output as The next expression parsed should be named Continue accepting strings until the user enters Ctrl-D for end of file. You do not need to implement a quit command.
    Here are some example REGEXP to NDFA examples:

    REGEXP DOT file DOT image (NDFA)
        node0 [shape = circle];
        node1 [shape = circle];
        node2 [shape = circle];
        node3 [shape = circle];
        node4 [shape = circle];
        node5 [shape = circle];
        start->node0 [label = "EPSILON"]
        node0->node1 [label = "EPSILON"]
        node0->node2 [label = "EPSILON"]
        node1->node3 [label = "a"]
        node2->node4 [label = "b"]
        node3->node5 [label = "EPSILON"]
        node4->node5 [label = "EPSILON"]
        node5->end [label = "EPSILON"]
        node0 [shape = circle];
        node1 [shape = circle];
        node2 [shape = circle];
        start->node0 [label = "EPSILON"]
        node0->node1 [label = "a"]
        node1->node2 [label = "EPSILON"]
        node2->node2 [label = "b"]
        node2->end [label = "EPSILON"]

Submission Guidelines

  1. Assignments must be submitted via Email.
    Email the Assignment to
    CC a copy to Professor Nowak
  2. The Title of the Email must be [CS360] Programming Assignment 3
  3. Attach all solutions in a single zip or tar.gz file. Name the file or username_a3.tar.gz where username is your drexel login. For example, mine would be Here is a useful website for making zip/tar.gz/etc in linux
  4. In the body of the email list all the files you are submitting. Give the name of the compressed file and a list of the contents. If any files are missing/corrupted, then I will know what you submitted.
  5. Submit one text file for each question. You should submit the following files:
    1. FCS.txt - Your answers for problem 1
    2. - Your modified version from lab 5 handling exponents.
    3. - Regular Expression Parser using PLY.
    4. You may include supporting files for your python implementation, for example, if you wrote a special class or library and stored it in a different file.
    5. test_input.txt - (Optional) a test file for the python parser. python < test_input.txt
  6. Each file should contain:
    1. Your Name
    2. Comments documenting all functions included in the file
    3. Your function definition
    4. Tests for your functions
  7. Submit a readme file containing the following:
    1. Your Name
    2. Email Address
    3. Example Execution Traces testing each of your functions
  8. All your code MUST run on