uthman
سه شنبه 19 آذر 1392, 18:23 عصر
سلام .کسی می تونه کد زیر رو به c# تبدیل کنه ؟خیلی لازمش دارم.
BooleanExp ::= VariableExp | AndExp| ‘(‘ BooleanExp ‘)’
VariableExp ::= ‘A’|’B’| ….|’X’|’Y’|’Z’
AndExp ::= BooleanExp ‘And’ BooleanExp
// defines an interface for all classes that define a
boolean expression.
class BooleanExp {
public:
BooleanExp();
Virtual bool Evaluate(Context&) = 0;
}
// defines a mapping from variables to boolean values.
class context {
public: void Assign(VariableExp*, bool); }
// represents a named variable
class VariableExp : public BooleanExp {
public:
VariableExp(const char*); }
// The constructor takes the variable name as an argument.
VariableExp:VariableExp (const char * name) {
_name = strdup(name); }
// Evaluating a variable returns its value in the current context
bool VariableExp:Evaluate (Context& aContext) {
Return aContext.Lookup(_name);
}
BooleanExp ::= VariableExp | AndExp| ‘(‘ BooleanExp ‘)’
VariableExp ::= ‘A’|’B’| ….|’X’|’Y’|’Z’
AndExp ::= BooleanExp ‘And’ BooleanExp
// defines an interface for all classes that define a
boolean expression.
class BooleanExp {
public:
BooleanExp();
Virtual bool Evaluate(Context&) = 0;
}
// defines a mapping from variables to boolean values.
class context {
public: void Assign(VariableExp*, bool); }
// represents a named variable
class VariableExp : public BooleanExp {
public:
VariableExp(const char*); }
// The constructor takes the variable name as an argument.
VariableExp:VariableExp (const char * name) {
_name = strdup(name); }
// Evaluating a variable returns its value in the current context
bool VariableExp:Evaluate (Context& aContext) {
Return aContext.Lookup(_name);
}