Implement an interpreter for a Simple Mathematical Expression Language (Call it "SMEL," if you like. ;-) ). Permissible Implementation Languages: C, C++ or Java Description of the Language: =========================== Language Support for Operations and Functions: The language supports both unary and binary operations, along with some built-in functions. The unary operations are unary minus and unary plus. The binary operations are +, -, *, /, % (remainder), and ^ (exponentiation). The built-in functions are sin, cos, tan, sqrt, exp, and abs (i.e., sine, cosine, tangent, square root, the constant E raised to some power, and absolute value). Notes: The values passed to the trigonometric functions MUST be in radians. (Converting from degrees to radians is accomplished by multiplying the degree value by PI/180.) In addition, the value passed to the square root function MUST be non-negative. Language Support for Numeric Types: Numeric types supported by the language include integer and floating point numbers. Language Support for Constants: The language also provides some built-in constants, namely PI (3.141593) and E (2.718282), required by the functions sin, cos, tan, and exp. Language Support for Inclusion Symbols: SMEL allows for the use of parentheses, which can be nested arbitrarily deeply. Language Support for Error-Checking: The reporting of errors in the event of: - A malformed mathematical expression (e.g., mismatched parentheses); - An unrecognized function, constant, or operation; - An attempt to divide by zero; - An attempt to take the square root of a negative number; - An attempt to compute the tangent of PI/2 or (3*PI)/2; and ... - An attempt to compute the remainder of two numbers, both of which are not integers; Interactive Features of the Language: Mathematical expressions entered by the user are processed as they are entered. The user types a single-line expression, followed by hitting . If the mathematical expression is valid, its value is printed immediately; otherwise, an error is reported. Sample Interactive Session: ========================== > 4 + 3 * 10 34 > sin(PI/6) 0.5 > 1.5 ^ 3 3.375 > sec(PI/2) Error: unrecognized function > (25 - 5) / (-2 - 2) -5 > exp(0) 1 > sqrt(-6.3) Error: negative argument > quit Good-bye
Bonus for 24 hour or less turnaround. Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased. Confidentiality!
Windows 98 or later
## Deadline information
Must be completed by 9/2/2002, 8:00am, EST, US. Please keep in mind that I'm a student when viewing my budget amount.