public override ComputedNode VisitComputedVariable(ComputedVariableContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("Context can't be null");
            }

            var id    = context.ID().GetText();
            var text  = Util.RemoveQuotes(context.TEXT().GetText());
            var qtype = Util.GetQValueTypeFromString(context.QTYPE().GetText());

            IExpressionNode expression = null;

            if (context.textConcatination() != null)
            {
                expression = new TextConcatinationVisitor().VisitTextConcatination(context.textConcatination());
            }

            else if (context.artithmeticExpression() != null)
            {
                expression = new ArthimetricExpressionVisitor().VisitArtithmeticExpression(context.artithmeticExpression());
            }

            else if (context.comparisonExpression() != null)
            {
                expression = new ComparisonExpressionVisitor().VisitComparisonExpression(context.comparisonExpression());
            }

            var computedNode = new ComputedNode(Location.FromContext(context), id, text, qtype, expression);

            return(computedNode);
        }
Exemplo n.º 2
0
        public override ComputedNode VisitComputedVariable([NotNull] QLanguageParser.ComputedVariableContext context)
        {
            var id      = context.ID().GetText();
            var textRaw = context.TEXT().GetText();
            var text    = textRaw.Substring(1, textRaw.Length - 2);
            var qtype   = (QValueType)Enum.Parse(typeof(QValueType), context.QTYPE().GetText().ToUpper());

            IExpressionNode expression = null;

            if (context.artithmeticExpression() != null)
            {
                expression = new ArthimetricExpressionVisitor().VisitArtithmeticExpression(context.artithmeticExpression());
            }

            else if (context.comparisonExpression() != null)
            {
                expression = new ComparisonExpressionVisitor().VisitComparisonExpression(context.comparisonExpression());
            }

            var computedNode = new ComputedNode(Location.FromContext(context), id, text, qtype, expression);

            return(computedNode);
        }