Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

  • a Scheme program in the file boolsimp.ss equivalent to the Java program that you are required to write;
  • a Java "stub" file boolSimp.dj1 that defines a composite hierarchy of "abstract syntax" tree classes rooted in the class Form representing boolean expressions;
  • a Java library file Parser.java contain a class Parser with
    • a read() method that reads a boolean expression represented in "Scheme form" and returns the corresponsing Java Form abstract syntax tree and
    • a (commented out) reduce() method that composes the visitors you must write in boolSimp.dj1 to simplify reduce whatever formula the Parser instance contains to simplified form.
  • a Java "stub" test file boolSimpTest.java that includes some rudimentary tests of the code in the boolSimp.dj1 stub file.

...

The visitor pattern is a straightforward but notationally involved 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 easier to write than the visitor solution described in the preceding program description. If you are still learning Java syntaxmechanics, you are encouraged to write an interpreter solution first and translate it (if you can) to visitor form. A perfect interpreter solution will only be penalized 15% versus a perfect visitor solution. If you submit an interpreter solution, you 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.

...

...