Example #1
0
        private static ulong GetNumberValue(NumberContext context)
        {
            string txt;

            var bin = context.NUMBERbin();

            if (bin is not null)
            {
                txt = bin.GetText();
                return(ParseNumber(2, 2, txt));
            }

            var oct = context.NUMBERoct();

            if (oct is not null)
            {
                txt = oct.GetText();
                return(ParseNumber(2, 8, txt));
            }

            var dec = context.NUMBERdec();

            if (dec is not null)
            {
                txt = dec.GetText();
                return(ParseNumber(0, 10, txt));
            }

            var decPre = context.NUMBERdec_prefix();

            if (decPre is not null)
            {
                txt = decPre.GetText();
                return(ParseNumber(2, 10, txt));
            }

            var hex = context.NUMBERhex();

            if (hex is not null)
            {
                txt = hex.GetText();
                return(ParseNumber(2, 16, txt));
            }

            var ch = context.CHARACTER();

            if (ch is not null)
            {
                txt = ch.GetText();
                return((UInt64)txt[0]);
            }

            return(0);
        }