Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 3

Microproject

Write a Scala program which reads a string from the user, and parses the input to determine if the input string matches the below grammar (i.e., is made up of a’s and b’s), building a parse tree along the way. Output the generated tree if the match is successful.

Read the below project description for assistance.

Main Project

Write a Scala program which simplifies logical expressions. Your program will read in logical expressions in C/Java/Scala format then parse them into a tree representation using case classes. You may do the parse in any way you wish. Only logical and (&&), or (||), and not (!) are supported. Parentheses may be used as part of the expressions. Precedence is captured by the below BNF-style grammar:

Once you have built the case class tree, you should simplify the given expression. Note that ‘and’ and ‘or’ expressions will always take two arguments, and ‘not’ will always take one. Once the simplification has been performed, print out the resulting expression. Again, use C/Java/Scala form.

Your program, when run, should ask the user for an input expression to simplify and print the output. It should continue doing so until the user terminates the program. 

Example run: