Ejemplo n.º 1
0
        public static INumberLiteral Scan(TextInputRange input)
        {
            var chr = input.EndChar;

            if (!IsDecimalDigit(chr))
            {
                return(null);
            }

            if (chr == '0')
            {
                var next = input.PeekChar();
                switch (next)
                {
                case 'x':
                case 'X':
                    input.Extend(nChars: 2);
                    return(ScanNumber(input, radix: 16, isDigit: IsHexDigit));

                case 'o':
                case 'O':
                    input.Extend(nChars: 2);
                    return(ScanNumber(input, radix: 8, isDigit: IsOctalDigit));

                case 'b':
                case 'B':
                    input.Extend(nChars: 2);
                    return(ScanNumber(input, radix: 2, isDigit: IsBinaryDigit));
                }
            }
            return(ScanDecimalNumber(input));
        }
Ejemplo n.º 2
0
        public void PeekCharEndTest()
        {
            var input = new TextInputRange {
                File = new TextFile {
                    Content  = "A",
                    Filename = ""
                }
            };

            Assert.AreEqual(expected: '\0', actual: input.PeekChar());
        }
Ejemplo n.º 3
0
        public void PeekCharStartTest()
        {
            var input = new TextInputRange {
                File = new TextFile {
                    Content  = "AB",
                    Filename = ""
                }
            };

            var t = input.PeekChar();

            Assert.AreEqual(expected: 'B', actual: t);
        }