CS245 Lab 2: Predictive Parser/Translator

Write a C++ program to translate expressions involving the binary operators +, -, *, and /, and single-digit integers, from Lisp notation into C++ notation. For example, the input

(+ (* 3 4) 5))

should be turned into

3 * 4 + 5

and

(* (+ 3 4) 5))

should be turned into

(3 + 4) * 5

Getting the parenthesis in the C++ expresision right may be somewhat hard - we won't take off much for having unnecessary parenthesis, but leaving out parenthesis that are important is definitely a problem.

Your program should respond to syntactically incorrect input by printing an error message and returning an error code other than 0 from main (this error code also be produced by calling the function "exit" when there's a problem). Your program only needs to translate one expression each time it is run.

You should use "/Stokes8/build/cvs_user_test/cvs_create 245 translator" to get the translator project, edit and add files there, and use cvs commit when you're done. The initial file you get for the translator simply copies the expression and takes out blank space (which is done automatically by "cin"), stopping when parenthesis are balanced.