Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

AbbreviationOriginal Symbol
Ttrue
Ffalse
!Not
&And
|Or
>Implies
?If

 

The Java abstract syntax classes include a separate composite hierarchy (called IfForm) for representing boolean expression as conditionals (the type ifExp in boolSimp.rkt). This representation includes only three concrete variant classes, making it much easier to write the visitors that perform normalization, evaluation, and convert-To-Bool.

...

The visitor pattern is a straightforward but notationally cumbersome alternative to the interpreter pattern. You can mechanically translate interpreter pattern code to visitor pattern code. (Perhaps IDEs like Eclipse should support such transformations.) The interpreter solution to this assignment is a bit easier to write than the visitor solution described in the preceding program description. If you are still learning Java mechanics, you are encouraged to write an interpreter solution first and perhaps translate it (if you can) later to visitor form. A perfect interpreter solution will only not be penalized 15% versus relative to a perfect visitor solution. If you submit an interpreter solution, your program must conform to class signatures given in the interpreter pattern support code below (just as a visitor solution must conform to the class signatures given in the visitor pattern code below).

The interpreter version of the support code replaces the ConvertToIf, Normalize, HeadNormalize, Evaluate, and Print visitors by methods named convertToIf, normalize, headNormalize, eval, and print.  The classes Parser.java and InterpParser.java contain references to the visitor class names and method names, respectively, in the API for the help functions assumed by our test code.   

Support Code

Here are the links for the files:

...