Exemple #1
0
 public INode Power()
 {
     INode node = Unary();
     while (true)
     {
         if (Accept("^"))
             node = new BinaryNode(node, Unary(), '^');
         else
             break;
     }
     return node;
 }
Exemple #2
0
 public INode SumSub()
 {
     INode node = MulDiv();
     while (true)
     {
         if (Accept("+"))
             node = new BinaryNode(node, MulDiv(), '+');
         else if (Accept("-"))
             node = new BinaryNode(node, MulDiv(), '-');
         else
             break;
     }
     return node;
 }
Exemple #3
0
 public INode MulDiv()
 {
     INode node = Power();
     while (true)
     {
         if (Accept("*"))
             node = new BinaryNode(node, Power(), '*');
         else if (Accept("/"))
             node = new BinaryNode(node, Power(), '/');
         else
             break;
     }
     return node;
 }
Exemple #4
0
 public INode Unary()
 {
     INode node = null;
     if (Accept("+"))
         node = Term();
     else if (Accept("-"))
         node = new BinaryNode(new ValueNode(0), Term(), '-');
     else
         node = Term();
     return node;
 }