// Returns NExprMul or any of subproduction nodes public Node ExprMul() { Node resultingNode = ExprPow(); while (CurrentToken == TokenCategory.MULTIPLICATION || CurrentToken == TokenCategory.DIVISION || CurrentToken == TokenCategory.MODULUS) { NExprMul tmp = new NExprMul(); tmp.Add(resultingNode); resultingNode = tmp; switch (CurrentToken) { case TokenCategory.MULTIPLICATION: { resultingNode.AnchorToken = Expect(TokenCategory.MULTIPLICATION); resultingNode.Add(ExprPow()); break; } case TokenCategory.DIVISION: { resultingNode.AnchorToken = Expect(TokenCategory.DIVISION); resultingNode.Add(ExprPow()); break; } case TokenCategory.MODULUS: { resultingNode.AnchorToken = Expect(TokenCategory.MODULUS); resultingNode.Add(ExprPow()); break; } // Default case would be unreachable } } return(resultingNode); }
public string Visit(NExprMul nExprMul) { string retVal = ""; if (nExprMul.children.Count == 1) { retVal += Visit((dynamic)nExprMul[0]); } else { retVal += Visit((dynamic)nExprMul[0]); retVal += Visit((dynamic)nExprMul[1]); switch (nExprMul.AnchorToken.Lexeme) { case "*": { retVal += "\t\tmul\n"; break; } case "/": { retVal += "\t\tdiv\n"; break; } case "%": { retVal += "\t\trem\n"; break; } } } return(retVal); }
//----------------------------------------------------------- public void Visit(NExprMul node) { VisitBinaryOperator('*', node /*, Type.INT*/); }
public void Visit(NExprMul nExprMul) { GenericChildVisitor(nExprMul); }