コード例 #1
0
        private ParsingEvent ParseBlockMappingKey(bool isFirst)
        {
            if (isFirst)
            {
                GetCurrentToken();
                Skip();
            }
            if (GetCurrentToken() is Key)
            {
                Mark end = GetCurrentToken().End;
                Skip();
                if (!(GetCurrentToken() is Key) && !(GetCurrentToken() is Value) && !(GetCurrentToken() is BlockEnd))
                {
                    states.Push(ParserState.BlockMappingValue);
                    return(ParseNode(true, true));
                }
                state = ParserState.BlockMappingValue;
                return(ProcessEmptyScalar(end));
            }
            if (GetCurrentToken() is BlockEnd)
            {
                state = states.Pop();
                ParsingEvent result = new MappingEnd(GetCurrentToken().Start, GetCurrentToken().End);
                Skip();
                return(result);
            }
            Token token = GetCurrentToken();

            throw new SemanticErrorException(token.Start, token.End, "While parsing a block mapping, did not find expected key.");
        }
コード例 #2
0
 public YamlMapping()
 {
     _mappingStart = new MappingStart();
     _mappingEnd   = new MappingEnd();
     _keys         = new List <YamlElement>();
     _contents     = new Dictionary <YamlElement, YamlElement>();
 }
コード例 #3
0
        public void addNode(MappingEnd end, List <string> path)
        {
            var linkedNode = this.AddNode(path);

            linkedNode.MappedEnd = end;
            //check if we need to use createPath() to fill the voids in the path
        }
コード例 #4
0
ファイル: Parser.cs プロジェクト: radiomonter/Tanki_X
        private ParsingEvent ParseBlockMappingKey(bool isFirst)
        {
            if (isFirst)
            {
                this.GetCurrentToken();
                this.Skip();
            }
            if (this.GetCurrentToken() is Key)
            {
                Mark end = this.GetCurrentToken().End;
                this.Skip();
                if (!(this.GetCurrentToken() is Key) && (!(this.GetCurrentToken() is Value) && !(this.GetCurrentToken() is BlockEnd)))
                {
                    this.states.Push(ParserState.BlockMappingValue);
                    return(this.ParseNode(true, true));
                }
                this.state = ParserState.BlockMappingValue;
                return(ProcessEmptyScalar(end));
            }
            if (!(this.GetCurrentToken() is BlockEnd))
            {
                Token currentToken = this.GetCurrentToken();
                throw new SemanticErrorException(currentToken.Start, currentToken.End, "While parsing a block mapping, did not find expected key.");
            }
            this.state = this.states.Pop();
            ParsingEvent event2 = new MappingEnd(this.GetCurrentToken().Start, this.GetCurrentToken().End);

            this.Skip();
            return(event2);
        }
コード例 #5
0
        public void addNode(MappingEnd mappedEnd, bool source)
        {
            var path = mappedEnd.fullMappingPath.Split('.').ToList();

            if (source)
            {
                this.trees.SourceTree.addNode(mappedEnd, path);
            }
            else
            {
                this.trees.TargetTree.addNode(mappedEnd, path);
            }
            //make sure the new node is visible?
            this.trees.ExpandAll();
        }
コード例 #6
0
ファイル: Parser.cs プロジェクト: radiomonter/Tanki_X
        private ParsingEvent ParseFlowMappingKey(bool isFirst)
        {
            if (isFirst)
            {
                this.GetCurrentToken();
                this.Skip();
            }
            if (!(this.GetCurrentToken() is FlowMappingEnd))
            {
                if (!isFirst)
                {
                    switch (this.GetCurrentToken())
                    {
                    case (FlowEntry _):
                        break;

                    default:
                    {
                        Token currentToken = this.GetCurrentToken();
                        throw new SemanticErrorException(currentToken.Start, currentToken.End, "While parsing a flow mapping,  did not find expected ',' or '}'.");
                        break;
                    }
                    }
                    this.Skip();
                }
                if (this.GetCurrentToken() is Key)
                {
                    this.Skip();
                    if (!(this.GetCurrentToken() is Value) && (!(this.GetCurrentToken() is FlowEntry) && !(this.GetCurrentToken() is FlowMappingEnd)))
                    {
                        this.states.Push(ParserState.FlowMappingValue);
                        return(this.ParseNode(false, false));
                    }
                    this.state = ParserState.FlowMappingValue;
                    return(ProcessEmptyScalar(this.GetCurrentToken().Start));
                }
                if (!(this.GetCurrentToken() is FlowMappingEnd))
                {
                    this.states.Push(ParserState.FlowMappingEmptyValue);
                    return(this.ParseNode(false, false));
                }
            }
            this.state = this.states.Pop();
            ParsingEvent event2 = new MappingEnd(this.GetCurrentToken().Start, this.GetCurrentToken().End);

            this.Skip();
            return(event2);
        }
コード例 #7
0
        private ParsingEvent ParseFlowMappingKey(bool isFirst)
        {
            if (isFirst)
            {
                GetCurrentToken();
                Skip();
            }
            if (!(GetCurrentToken() is FlowMappingEnd))
            {
                if (!isFirst)
                {
                    if (!(GetCurrentToken() is FlowEntry))
                    {
                        Token token = GetCurrentToken();
                        throw new SemanticErrorException(token.Start, token.End, "While parsing a flow mapping,  did not find expected ',' or '}'.");
                    }
                    Skip();
                }
                if (GetCurrentToken() is Key)
                {
                    Skip();
                    if (!(GetCurrentToken() is Value) && !(GetCurrentToken() is FlowEntry) && !(GetCurrentToken() is FlowMappingEnd))
                    {
                        states.Push(ParserState.FlowMappingValue);
                        return(ParseNode(false, false));
                    }
                    state = ParserState.FlowMappingValue;
                    return(ProcessEmptyScalar(GetCurrentToken().Start));
                }
                if (!(GetCurrentToken() is FlowMappingEnd))
                {
                    states.Push(ParserState.FlowMappingEmptyValue);
                    return(ParseNode(false, false));
                }
            }
            state = states.Pop();
            ParsingEvent result = new MappingEnd(GetCurrentToken().Start, GetCurrentToken().End);

            Skip();
            return(result);
        }
コード例 #8
0
        YamlMapping(MappingStart mappingStart, MappingEnd mappingEnd, List <YamlElement> keys, Dictionary <YamlElement, YamlElement> contents, YamlNodeTracker tracker)
        {
            Tracker = tracker;

            MappingStart     = mappingStart;
            this._mappingEnd = mappingEnd;

            if (Tracker == null)
            {
                _keys     = keys;
                _contents = contents;
            }
            else
            {
                _keys     = new List <YamlElement>();
                _contents = new Dictionary <YamlElement, YamlElement>();
                foreach (var key in keys)
                {
                    Add(key, contents[key]);
                }
            }
        }
コード例 #9
0
 void IParsingEventVisitor.Visit(MappingEnd e)
 {
     clonedEvent = new MappingEnd(e.Start, e.End);
 }
コード例 #10
0
 public void Visit(MappingEnd e)
 {
     _branches.Pop();
     _currentPath.Pop();
 }
コード例 #11
0
 public void Visit(MappingEnd e)
 {
     _emitter.Emit(e);
     _branches.Pop();
     _currentPath.Pop();
 }