コード例 #1
0
 private Expression.Expression ConvertPower(PowerNode node)
 {
     return(new Power
     {
         Left = ConvertToExpression(node.Left),
         Right = ConvertToExpression(node.Right)
     });
 }
コード例 #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);
        }