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

SaveSimpleKey() private method

Check if a simple key may start at the current position and add it if needed.
private SaveSimpleKey ( ) : void
return void
        private void SaveSimpleKey()
        {
            // A simple key is required at the current position if the scanner is in
            // the block context and the current column coincides with the indentation
            // level.

            bool isRequired = (flowLevel == 0 && indent == cursor.LineOffset);

            // A simple key is required only when it is the first token in the current
            // line.  Therefore it is always allowed.  But we add a check anyway.

            Debug.Assert(simpleKeyAllowed || !isRequired, "Can't require a simple key and disallow it at the same time.");    // Impossible.

            // If the current position may start a simple key, save it.

            if (simpleKeyAllowed)
            {
                var key = new SimpleKey(true, isRequired, tokensParsed + tokens.Count, cursor);

                RemoveSimpleKey();

                simpleKeys.Pop();
                simpleKeys.Push(key);
            }
        }