コード例 #1
0
ファイル: Parser.cs プロジェクト: Turee/SharpYaml
        /// <summary>
        /// Parse the productions:
        /// flow_sequence        ::= FLOW-SEQUENCE-START
        ///                          *******************
        ///                          (flow_sequence_entry FLOW-ENTRY)*
        ///                           *                   **********
        ///                          flow_sequence_entry?
        ///                          *
        ///                          FLOW-SEQUENCE-END
        ///                          *****************
        /// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?
        ///                          *
        /// </summary>
        private Event ParseFlowSequenceEntry(bool isFirst)
        {
            if (isFirst)
            {
                GetCurrentToken();
                Skip();
            }

            Event evt;

            if (!(GetCurrentToken() is FlowSequenceEnd))
            {
                if (!isFirst)
                {
                    if (GetCurrentToken() is FlowEntry)
                    {
                        Skip();
                    }
                    else
                    {
                        var current = GetCurrentToken();
                        throw new SemanticErrorException(current.Start, current.End, "While parsing a flow sequence, did not find expected ',' or ']'.");
                    }
                }

                if (GetCurrentToken() is Key)
                {
                    state = ParserState.YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
                    evt   = new Events.MappingStart(null, null, true, YamlStyle.Flow);
                    Skip();
                    return(evt);
                }
                else if (!(GetCurrentToken() is FlowSequenceEnd))
                {
                    states.Push(ParserState.YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE);
                    return(ParseNode(false, false));
                }
            }

            state = states.Pop();
            evt   = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End);
            Skip();
            return(evt);
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: modulexcite/SharpYaml
		/// <summary>
		/// Parse the productions:
		/// flow_sequence        ::= FLOW-SEQUENCE-START
		///                          *******************
		///                          (flow_sequence_entry FLOW-ENTRY)*
		///                           *                   **********
		///                          flow_sequence_entry?
		///                          *
		///                          FLOW-SEQUENCE-END
		///                          *****************
		/// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?
		///                          *
		/// </summary>
		private Event ParseFlowSequenceEntry(bool isFirst)
		{
			if (isFirst)
			{
				GetCurrentToken();
				Skip();
			}

			Event evt;
			if (!(GetCurrentToken() is FlowSequenceEnd))
			{
				if (!isFirst)
				{
					if (GetCurrentToken() is FlowEntry)
					{
						Skip();
					}
					else
					{
						var current = GetCurrentToken();
						throw new SemanticErrorException(current.Start, current.End, "While parsing a flow sequence, did not find expected ',' or ']'.");
					}
				}

				if (GetCurrentToken() is Key)
				{
					state = ParserState.YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
					evt = new Events.MappingStart(null, null, true, YamlStyle.Flow);
					Skip();
					return evt;
				}
				else if (!(GetCurrentToken() is FlowSequenceEnd))
				{
					states.Push(ParserState.YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE);
					return ParseNode(false, false);
				}
			}

			state = states.Pop();
			evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End);
			Skip();
			return evt;
		}
コード例 #3
0
 protected override string GetDefaultTag(MappingStart nodeEvent)
 {
     return MapShortTag;
 }