Fall 2015 CSE 425 Lab 2: Parsing and Matching Predicates in C++

Due by Tuesday October 27, 2015, at 11:59 pm
(deadline for email receipt of a .zip file with your solution)
Final grade percentage: 15 percent

As with the previous lab you are allowed (and in fact encouraged) to work in teams of 2 or 3 people (but not more), though you also are allowed to work individually if you prefer.


This lab is intended to continue to broaden your experience with programming language features and design approaches in C++, as well as to work specifically with expression parsing, representation, and matching techniques (again using Horn clauses from logic programming as a specific example), including:

In this lab assignment, you will develop (in C++ in Visual Studio 2013 on the Windows lab machines) a new executable program that processes command line arguments, reads expressions from a file, and parses them. The emphasis for this assignment is on the internal processing, representation, and matching activites the program will perform. Specifically, in this assignment, you will extend your solution from the previous lab assignment to (1) read and parse an input file as a stream of Horn clauses according to the parenthesized notation described by the input grammar defined below (2) construct and store representations of those elements according to their types and other attributes; and (3) perform basic matching operations to see if different instances of those elements are compatible, based on the idea of unification from logic programming.

In the next (and final lab) assignment this semester, we will extend this program to perform resolution, further semantic evaluation, and query processing of Horn clauses. The design and implementation decisions you make in this assignment also will impact the design and implementation decisions for the next lab assignment, and so you are encouraged to think ahead where possible as you design your solution to this assignment.


    Part I - Readings and Resources:

  1. The following readings in the course text book may be useful as reference material while working on this lab assignment:

  2. The following on-line resource also may be useful while working on this lab assignment:

    Part II - Program Design and Implementation:

    Note: the details of this assignment are again intentionally somewhat under-specified, leaving you some room to choose what you think is the best way to implement them, as long as what you do is reasonable and you explain your design decisions in comments in the code and in your project report.

  3. Open up Visual Studio 2013 and create a new C++ Win32 Console Application project for this lab assignment, and copy over your program source and header files from the previous lab into the directory for the new project, and then add them to the project.

    As you implement your solution to this lab, please feel free to declare and define new structs, classes, enumerations, functions, and other types that are helpful in the design and implementation of your lab solution. As you do that please maintain good modularity of your implementation at the file level as well as at the type level, e.g., giving each major abstraction like a class and its related functions and enumerations its own separate header (.h) file and source (.cpp) file.

  4. The program should again check that the input file can be opened for reading, and if not should display a helpful usage message and then return a unique non-zero error code; otherwise the program should read in the contents of the input file as a sequence of tokens and process that sequence as follows.

  5. To make sure that the features of your program are working correctly, run the executable program through a series of trials that test it with good coverage of cases involving both well formed and badly formed command lines, with existing and missing files, and with input files containing different well formed and badly formed input Horn clauses with line breaks in different places, etc., in as many possible combinations as you can think of.

    In your project report please document which test cases you ran, and summarize what your program did and whether what you saw was or was not correct behavior (and why or why not) in each case.

  6. Prepare a .zip file that contains all of your project's C++ code (source and header) files, input/output traces for the important cases you tested, and your project report. Send the .zip file containing your lab 2 solution as an e-mail attachment to the course e-mail account (cse425@seas.wustl.edu) by the submission deadline for this assignment. If you need to make changes to your lab solution you are welcome to send a new .zip file, and we will grade the latest one received prior to the deadline (according to the time stamp the server puts on the e-mail).

    IMPORTANT:please make sure that no .exe file is included in any .zip file you send, as the WUSTL e-mail servers will block delivery of email with a .zip attachment that includes a .exe file. Please also make sure to send a .zip file (not a .7z file or other zip format) when you send your solutions.

    Part III - Extra Credit (1 to 5 percent of assignment's value depending on quality and completeness):

  7. Optionally, before your program adds any predicate to the symbol table, have it check whether or not any predicate already in the symbol table is identical to it (i.e., they have the same name and the ordered sequence of tokens for their symbols is exactly the same), and if so should print out a message indicating that it has found (and is skipping) the predicate instead of adding it to the symbol table (the message should also print out the skipped predicate's name and symbols so it's clear which predicates were added and which were skipped).

    Please add an extra credit section to your project report documenting your design and implementation of that additional capability. In that same section, please show examples of input and output from the different cases that you tested in order to validate that it is working correctly.

    Please submit both the required and extra credit portions within the same code base, along with your project report.

Posted 10am Monday October 5, 2015 by
Chris Gill