My professor asked me to write a program in c++ .This is the
description of the program:
A program in the language is made up of a sequence of statements.
Each statement is either an assignment statement or a print
statement. All statements are terminated by a semicolon (. There
are no control statements of any kind, and execution always proceeds
from the first to last statement.
An assignment statement is made up of a variable on the right hand
side, an equal sign (=) and an expression on the right hand side.
Variables need not be declared before they are used.
Print statements consist of the keyword PRINT (any case) followed by
a list of expressions separated by commas. When the print statement
executes the values of the variables will be tab separated and
printed on a line. Print statements will always print a newline after
printing their list of variables.
Expressions may be simple variables or constant values, or they may
include infix operations like multiplication, division, addition,
subtraction and power (*, /, +, -, ^). Also the minus sign (-) serves
a dual purpose as the infix subtraction operator and a prefix
negation operator. The order of execution rules are the standard ones
for these operations (negation, power, divide and multiply, and
addition and subtraction). Given the same precedence level,
expressions are executed left-to-right. Parenthesis can be used to
override the order of execution.
Variables may be any valid identifier that is not a keyword (The only
keyword is 'PRINT'). Variables are automatically declared when they
are first used. Variables that have not been assigned to have a value
Values are real numbers and should be internally represented as a
double- precision floating point number, even if they do not include
a decimal point.
The simplify method::
The simplify method will transform the expression subtrees into a
more abstract representation. The exact transformation depends on
your grammar, but the idea is to remove the extra non-terminals
needed to take care of the order of execution rules. The result
should be a correctly ordered tree whose nodes are all arithmetic
operations or simple values. Note that this will also remove the node
needed to handle parenthesis.
The dump method
The dump method should print an indented list the nodes and what they
contain. For example, the output for this statement: X = X*2+Y might
look like this:
To make this work you will have to pass the dump method the current
indention level (probably an integer) and increment it when you call
your children nodes.
the program is due 10/10/2001. This program worths 10% of the class
I am not good in c++ and I realy need your help on this. I am willing
to pay for whoever write the program for me. Please e-mail me ..
Thank you and you have a good day....