/// <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 ParsingEvent ParseFlowSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } ParsingEvent 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.FlowSequenceEntryMappingKey; evt = new Events.MappingStart(null, null, true, MappingStyle.Flow); Skip(); return(evt); } else if (!(GetCurrentToken() is FlowSequenceEnd)) { states.Push(ParserState.FlowSequenceEntry); return(ParseNode(false, false)); } } state = states.Pop(); evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End); Skip(); return(evt); }
/// <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 ParsingEvent ParseFlowSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } ParsingEvent evt; var current = GetCurrentToken(); if (!(current is FlowSequenceEnd)) { if (!isFirst) { if (current is FlowEntry) { Skip(); current = GetCurrentToken(); } else { throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a flow sequence, did not find expected ',' or ']'."); } } if (current is Key) { state = ParserState.FlowSequenceEntryMappingKey; evt = new Events.MappingStart(AnchorName.Empty, TagName.Empty, true, MappingStyle.Flow); Skip(); return evt; } else if (!(current is FlowSequenceEnd)) { states.Push(ParserState.FlowSequenceEntry); return ParseNode(false, false); } } state = states.Pop(); evt = new Events.SequenceEnd(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty); Skip(); return evt; }
/// <summary> /// Parse the productions: /// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END /// ******************** *********** * ********* /// </summary> private Event ParseBlockSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } if (GetCurrentToken() is BlockEntry) { Mark mark = GetCurrentToken().End; Skip(); if (!(GetCurrentToken() is BlockEntry || GetCurrentToken() is BlockEnd)) { states.Push(ParserState.YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE); return(ParseNode(true, false)); } else { state = ParserState.YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE; return(ProcessEmptyScalar(mark)); } } else if (GetCurrentToken() is BlockEnd) { state = states.Pop(); Event evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End); Skip(); return(evt); } else { var current = GetCurrentToken(); throw new SemanticErrorException(current.Start, current.End, "While parsing a block collection, did not find expected '-' indicator."); } }
/// <summary> /// Parse the productions: /// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END /// ******************** *********** * ********* /// </summary> private ParsingEvent ParseBlockSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } var current = GetCurrentToken(); if (current is BlockEntry blockEntry) { Mark mark = blockEntry.End; Skip(); current = GetCurrentToken(); if (!(current is BlockEntry || current is BlockEnd)) { states.Push(ParserState.BlockSequenceEntry); return(ParseNode(true, false)); } else { state = ParserState.BlockSequenceEntry; return(ProcessEmptyScalar(mark)); } } else if (current is BlockEnd blockEnd) { state = states.Pop(); ParsingEvent evt = new Events.SequenceEnd(blockEnd.Start, blockEnd.End); Skip(); return(evt); } else { throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a block collection, did not find expected '-' indicator."); } }
/// <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 ParsingEvent ParseFlowSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } ParsingEvent 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.FlowSequenceEntryMappingKey; evt = new Events.MappingStart(null, null, true, MappingStyle.Flow); Skip(); return evt; } else if (!(GetCurrentToken() is FlowSequenceEnd)) { states.Push(ParserState.FlowSequenceEntry); return ParseNode(false, false); } } state = states.Pop(); evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End); Skip(); return evt; }
/// <summary> /// Parse the productions: /// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END /// ******************** *********** * ********* /// </summary> private ParsingEvent ParseBlockSequenceEntry(bool isFirst) { if (isFirst) { GetCurrentToken(); Skip(); } if (GetCurrentToken() is BlockEntry) { Mark mark = GetCurrentToken().End; Skip(); if (!(GetCurrentToken() is BlockEntry || GetCurrentToken() is BlockEnd)) { states.Push(ParserState.BlockSequenceEntry); return ParseNode(true, false); } else { state = ParserState.BlockSequenceEntry; return ProcessEmptyScalar(mark); } } else if (GetCurrentToken() is BlockEnd) { state = states.Pop(); ParsingEvent evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End); Skip(); return evt; } else { var current = GetCurrentToken(); throw new SemanticErrorException(current.Start, current.End, "While parsing a block collection, did not find expected '-' indicator."); } }
void IParsingEventVisitor.Visit(SequenceEnd e) { clonedEvent = new SequenceEnd(e.Start, e.End); }