Homework 09: Symbolic Evaluation of Boolean Expressions in Java
Due: 10am WednesdayMonday, March 30April 4, 2011
Overview
Write a Java program boolSimp.dj1dj
that reduces boolean expressions (represented in the input and output streams in Scheme-like notation) to simplified form. For the purposes of this assignment, boolean expressions are Scheme expressions constructed from:
...
- a Scheme program in the file
boolsimp.ss
equivalent to the Java program that you are required to write; - a Java "stub" file
boolSimp.dj1dj
that defines a composite hierarchy of "abstract syntax" tree classes rooted in the classForm
representing boolean expressions; - a Java library file
Parser.java
contain a classParser
with- a
read()
method that reads a boolean expression represented in "Scheme form" and returns the corresponsing JavaForm
abstract syntax tree and - a
reduce()
method that composes the visitors you must write inboolSimp.dj1dj
to reduce whatever formula theParser
instance contains to simplified form.
- a
- a Java "stub" test file
boolSimpTest.java
that includes some rudimentary tests of the code in theboolSimp.dj1dj
stub file.
The stub file BoolSimp.dj1dj
also includes comments showing you exactly what code you have to write to complete writing your simplifier. Of course, you also need to write corresponding tests and add them to the file BoolSimpTest.java
.
...
If you omit the new File(...)
construction in the argument to Parser
and use "<fileName>"
instead, you will create a Parser
for the String "<fileName>"
. which is interpreted as a simple boolean variable. The File
input format is important because it enables us to conveniently apply your simplifier to formulas that are thousands of symbols long. As a result, you only have to translate the Scheme code in boolsimp.ss
into corresponding cleanly-written OO Java code by filling in the gaps in our Java stub file boolSimp.dj1dj
. You are expected to appropriately use the composite, interpreter, singleton, and visitor patterns in the code that you write. Since the only stub files that you have to modify are boolSimp.dj1dj
and boolSimpTest.java
, simply submit expanded versions of these files via OwlSpace to submit your assignment. Warning: we will run your program on large inputs to determine if you wrote the code correctly. Try using the large test files provided on the course wiki.
We have formatted the test files as a .java
file rather than a .dj1dj
because the Language Levels facility peforms no useful augmentation of JUnit test classes and bypassing the language levels translator avoids some annoying bugs in the implementation of that facility. When using the "Save As" command, please remember to save you file boolSimpTest.java
as a .java
file not as a .dj1dj
file. The "Save" command always retains the file types of all files.
...
- boolsimp.ss\ is the reference Scheme program.
- BoolSimp.dj1dj\ is a stub program for a visitor solution.
- BoolSimpTest.java\ is a stub test file for a visitor solution.
- Parser.java\ is a parser file for a visitor solution.
- InterpBoolSimp.dj1dj\ is a stub program for an interpreter solution.
- InterpBoolSimpTest.java\ is a stub test file for an interpreter solution.
- InterpParser.java\ is a parser file for an interpreter solution.
...