示例#1
0
        private void FetchValue()
        {
            SimpleKey key = this.simpleKeys.Peek();

            if (key.IsPossible)
            {
                this.tokens.Insert(key.TokenNumber - this.tokensParsed, new Key(key.Mark, key.Mark));
                this.RollIndent(key.LineOffset, key.TokenNumber, false, key.Mark);
                key.IsPossible        = false;
                this.simpleKeyAllowed = false;
            }
            else
            {
                if (this.flowLevel == 0)
                {
                    if (!this.simpleKeyAllowed)
                    {
                        Mark mark = this.cursor.Mark();
                        throw new SyntaxErrorException(mark, mark, "Mapping values are not allowed in this context.");
                    }
                    this.RollIndent(this.cursor.LineOffset, -1, false, this.cursor.Mark());
                }
                this.simpleKeyAllowed = this.flowLevel == 0;
            }
            Mark start = this.cursor.Mark();

            this.Skip();
            this.tokens.Enqueue(new Value(start, this.cursor.Mark()));
        }
示例#2
0
        private void FetchValue()
        {
            SimpleKey simpleKey = simpleKeys.Peek();

            if (simpleKey.IsPossible)
            {
                tokens.Insert(simpleKey.TokenNumber - tokensParsed, new Key(simpleKey.Mark, simpleKey.Mark));
                RollIndent(simpleKey.LineOffset, simpleKey.TokenNumber, false, simpleKey.Mark);
                simpleKey.IsPossible = false;
                simpleKeyAllowed     = false;
            }
            else
            {
                if (flowLevel == 0)
                {
                    if (!simpleKeyAllowed)
                    {
                        Mark mark = cursor.Mark();
                        throw new SyntaxErrorException(mark, mark, "Mapping values are not allowed in this context.");
                    }
                    RollIndent(cursor.LineOffset, -1, false, cursor.Mark());
                }
                simpleKeyAllowed = (flowLevel == 0);
            }
            Mark start = cursor.Mark();

            Skip();
            tokens.Enqueue(new Value(start, cursor.Mark()));
        }
示例#3
0
        private void RemoveSimpleKey()
        {
            SimpleKey key = this.simpleKeys.Peek();

            if (key.IsPossible && key.IsRequired)
            {
                throw new SyntaxErrorException(key.Mark, key.Mark, "While scanning a simple key, could not find expected ':'.");
            }
            key.IsPossible = false;
        }
示例#4
0
        private void SaveSimpleKey()
        {
            bool isRequired = (this.flowLevel == 0) && (this.indent == this.cursor.LineOffset);

            if (this.simpleKeyAllowed)
            {
                SimpleKey t = new SimpleKey(true, isRequired, this.tokensParsed + this.tokens.Count, this.cursor);
                this.RemoveSimpleKey();
                this.simpleKeys.Pop();
                this.simpleKeys.Push(t);
            }
        }
示例#5
0
        private void SaveSimpleKey()
        {
            bool flag = flowLevel == 0 && indent == cursor.LineOffset;

            Debug.Assert(simpleKeyAllowed || !flag, "Can't require a simple key and disallow it at the same time.");
            if (simpleKeyAllowed)
            {
                SimpleKey t = new SimpleKey(true, flag, tokensParsed + tokens.Count, cursor);
                RemoveSimpleKey();
                simpleKeys.Pop();
                simpleKeys.Push(t);
            }
        }
示例#6
0
        /// <summary>
        /// Check if a simple key may start at the current position and add it if
        /// needed.
        /// </summary>
        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 == mark.Column);

            // 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)
            {
                SimpleKey key = new SimpleKey(true, isRequired, tokensParsed + tokens.Count, mark);

                RemoveSimpleKey();

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