示例#1
0
        public override SqlObject VisitUnaryScalarExpression([NotNull] sqlParser.UnaryScalarExpressionContext context)
        {
            Contract.Requires(context != null);
            // unary_operator scalar_expression
            Contract.Requires(context.ChildCount == 2);

            string unaryOperatorText = context.unary_operator().GetText();

            if (!CstToAstVisitor.unaryOperatorKindLookup.TryGetValue(
                    unaryOperatorText,
                    out SqlUnaryScalarOperatorKind unaryOperator))
            {
                throw new ArgumentOutOfRangeException($"Unknown unary operator: {unaryOperatorText}.");
            }

            SqlScalarExpression expression = (SqlScalarExpression)this.Visit(context.scalar_expression());

            return(SqlUnaryScalarExpression.Create(unaryOperator, expression));
        }
示例#2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>UnaryScalarExpression</c>
 /// labeled alternative in <see cref="sqlParser.scalar_expression"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitUnaryScalarExpression([NotNull] sqlParser.UnaryScalarExpressionContext context)
 {
     return(VisitChildren(context));
 }