public INode Power() { INode node = Unary(); while (true) { if (Accept("^")) node = new BinaryNode(node, Unary(), '^'); else break; } return node; }
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; }
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; }
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; }