YamlDotNet.Core.Scanner.ScanVersionDirectiveNumber C# (CSharp) Method

ScanVersionDirectiveNumber() private method

Scan the version number of VERSION-DIRECTIVE. Scope: %YAML 1.1 # a comment \n ^ %YAML 1.1 # a comment \n ^
private ScanVersionDirectiveNumber ( YamlDotNet.Core.Mark start ) : int
start YamlDotNet.Core.Mark
return int
        private int ScanVersionDirectiveNumber(Mark start)
        {
            int value = 0;
            int length = 0;

            // Repeat while the next character is digit.

            while (analyzer.IsDigit())
            {
                // Check if the number is too long.

                if (++length > MaxVersionNumberLength)
                {
                    throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %YAML directive, find extremely long version number.");
                }

                value = value * 10 + analyzer.AsDigit();

                Skip();
            }

            // Check if the number was present.

            if (length == 0)
            {
                throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %YAML directive, did not find expected version number.");
            }

            return value;
        }