Beispiel #1
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="CodeQueryParser.ConstantNumber" />.
        /// <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>
        public override Object VisitConstantNumber(CodeQueryParser.ConstantNumberContext context)
        {
            Double value;

            if (!Double.TryParse(context.NUMBER().GetText(), out value))
            {
                throw new Exception("Invalid number!");
            }
            return(TreeFactory.CreateNumber(value));
        }
Beispiel #2
0
        public override CodeQueryVisitor VisitConstantNumber(CodeQueryParser.ConstantNumberContext context)
        {
            Double value;

            if (!Double.TryParse(context.NUMBER().GetText(), out value))
            {
                throw new Exception("Invalid number!");
            }
            _constants.Push(value);

            return(base.VisitConstantNumber(context));
        }