0

I was wondering if yall knew how to construct the parameter "input" i have below so that it can be thrown into a parser and used to create a tree. This is an infix postfix program that is based on classes and uses variable expressions. If you need more info let me know

arithmetic_expression::arithmetic_expression(RPNstring input)  //constructor
{


}

arithmetic_expression::arithmetic_expression(const arithmetic_expression &inExpression)
{





}

Rpnstring coming from

#ifndef AE_H
#define AE_H

class RPNstring
{
public:
RPNstring(std::string inString){ expression = inString; };
std::string getString(){return(expression);}

private:
std::string expression;
};

class Infixstring
{
public:
Infixstring(std::string inString){ expression = inString; };
std::string getString(){return(expression);};
private:
std::string expression;
};

class arithmetic_expression
{
public:
arithmetic_expression(RPNstring inString);
arithmetic_expression(Infixstring inString);
arithmetic_expression(const arithmetic_expression &inExpression);  //Copy constructor
~arithmetic_expression();  //Destructor
arithmetic_expression & operator=(const arithmetic_expression &inExpression); //assignment          operator
void printRPN();
void printInfix();
int evaluate_Expression(std::map< std::string, int > ipmap);

and

RPNstring in1("3  2 + xyz *");
arithmetic_expression expression1(in1);
std::cout<<"Expression 1"<< std::endl;
expression1.printInfix();
expression1.printRPN();
std::cout<<"----

and inString from

class Tree
{
public:
Tree(std::string input,Tree *leftSubTree=NULL,Tree *rightSubTree=NULL);
Tree(const Tree &inTree);   //COPY CONSTRUCTOR
~Tree(); //DESTRUCTOR

and also...

Tree::Tree(std::string input,Tree *leftSubTree,Tree *rightSubTree){
Op = input;
leftPtr = leftSubTree;
rightPtr = rightSubTree;
int num;
if (input == "+"|input == "-"|input == "*"|input == "/")
            NodeType = TYPE_OPERATOR;
else if(std::istringstream(Op)>>num)
    NodeType = TYPE_NUMBER;
else
    NodeType = TYPE_VARIABLE;
4

0 回答 0