private Expression.Expression ConvertAddition(AdditionNode node)
 {
     return(new Addition
     {
         Left = ConvertToExpression(node.Left),
         Right = ConvertToExpression(node.Right)
     });
 }
Ejemplo n.º 2
0
        public override ASTNode VisitBinaryOperatorExpression([NotNull] DAEImplicitGrammarParser.BinaryOperatorExpressionContext context)
        {
            InfixExpressionNode node;
            int type = context.op.Type;

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

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

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

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

            case DAEImplicitGrammarLexer.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);
        }