示例#1
0
        public UstNode VisitPatternInt([NotNull] DslParser.PatternIntContext context)
        {
            long resultValue;

            if (context.PatternOct() != null)
            {
                resultValue = System.Convert.ToInt64(context.PatternOct().GetText(), 8);
            }
            else if (context.PatternInt() != null)
            {
                resultValue = long.Parse(context.PatternInt().GetText());
            }
            else
            {
                resultValue = System.Convert.ToInt64(context.PatternHex().GetText(), 16);
            }
            return(new IntLiteral(resultValue, context.GetTextSpan(), null));
        }
示例#2
0
        public PatternUst VisitPatternInt([NotNull] DslParser.PatternIntContext context)
        {
            if (context.PatternInt() != null)
            {
                var text = context.PatternInt().GetText();
                if (long.TryParse(text, out long longValue))
                {
                    return(new PatternIntLiteral(longValue, context.GetTextSpan()));
                }
                else
                {
                    return(new PatternBigIntLiteral(BigInteger.Parse(text), context.GetTextSpan()));
                }
            }

            long resultValue = context.PatternOct() != null
                ? System.Convert.ToInt64(context.PatternOct().GetText(), 8)
                : System.Convert.ToInt64(context.PatternHex().GetText(), 16);

            return(new PatternIntLiteral(resultValue, context.GetTextSpan()));
        }