private Expression.Expression ConvertPower(PowerNode node)
 {
     return(new Power
     {
         Left = ConvertToExpression(node.Left),
         Right = ConvertToExpression(node.Right)
     });
 }
        public override ASTNode VisitBinaryOperatorExpression(EquationGrammarParser.BinaryOperatorExpressionContext context)
        {
            InfixExpressionNode node;
            int type = context.op.Type;

            switch (type)
            {
            case EquationGrammarLexer.CARET:
                node = new PowerNode();
                break;

            case EquationGrammarLexer.PLUS:
                node = new AdditionNode();
                break;

            case EquationGrammarLexer.MINUS:
                node = new SubtractionNode();
                break;

            case EquationGrammarLexer.ASTERISK:
                node = new MultiplicationNode();
                break;

            case EquationGrammarLexer.DIVISION:
                node = new DivisionNode();
                break;

            default:
                throw new NotSupportedException();
            }
            node.Left     = (ExpressionNode)Visit(context.left);
            node.Right    = (ExpressionNode)Visit(context.right);
            node.Line     = context.start.Line;
            node.Position = context.start.Column;
            return(node);
        }