Advance() публичный Метод

Moves current position forward or backward
public Advance ( int offset ) : void
offset int Offset to move by
Результат void
Пример #1
0
        // public static object CharacterSteam { get; private set; }

        public static int HandleNumber(CharacterStream cs) {
            int start = cs.Position;

            if (cs.CurrentChar == '-' || cs.CurrentChar == '+') {
                cs.MoveToNextChar();
            }

            if (cs.CurrentChar == '0' && cs.NextChar == 'x') {
                cs.Advance(2);
                return HandleHex(cs, start);
            }

            if (cs.CurrentChar == 'x' && CharacterStream.IsHex(cs.NextChar)) {
                cs.MoveToNextChar();
                return HandleHex(cs, start);
            }

            int integerPartStart = cs.Position;
            int integerPartLength = 0;
            int fractionPartLength = 0;
            bool isDouble = false;

            // collect decimals (there may be none like in .1e+20
            while (cs.IsDecimal()) {
                cs.MoveToNextChar();
                integerPartLength++;
            }

            if (cs.CurrentChar == '.') {
                isDouble = true;

                // float/double
                cs.MoveToNextChar();

                // If we've seen don we need to collect factional part of any
                while (cs.IsDecimal()) {
                    cs.MoveToNextChar();
                    fractionPartLength++;
                }
            }

            if (integerPartLength + fractionPartLength == 0) {
                return 0; // +e or +.e is not a number and neither is lonely + or -
            }

            int numberLength;
            if (cs.CurrentChar == 'e' || cs.CurrentChar == 'E') {
                isDouble = true;
                numberLength = HandleExponent(cs, start);
            } else {
                numberLength = cs.Position - start;
            }

            // Verify double format
            if (isDouble && !IsValidDouble(cs, start, cs.Position)) {
                numberLength = 0;
            }

            if (numberLength > 0) {
                // skip over trailing 'L' if any
                if (cs.CurrentChar == 'L') {
                    cs.MoveToNextChar();
                    numberLength++;
                }
            }

            return numberLength;
        }