def _create_record_node(self): """Creates a record node.""" node = MappingDataNode() start_mark = self._event.start_mark end_mark = self._event.end_mark self._next_parse_event() # create children while (self._event is not None and not isinstance(self._event, pyyaml.MappingEndEvent)): key = self._create_record_key() self._next_parse_event() # value event if not key: # if key is invalid continue if self._event is None: break # something went wrong, abandon ship! if key.value == '<<': # handle merge self._perform_merge(key, node) self._next_parse_event() continue child_node = self._create_node(node) self._next_parse_event() if child_node is None: # i.e. unresolved alias continue child_node.key = key node.set_child(child_node) if self._event is not None: # update end_mark when map ends correctly end_mark = self._event.end_mark elif node.children: end_mark = node.children[-1].span.end end_mark.line -= 1 end_mark.column -= 1 node.span = Span.from_marks(start_mark, end_mark) return node
def _create_array_node(self): """Creates an array node.""" node = SequenceDataNode() start_mark = self._event.start_mark end_mark = self._event.end_mark self._next_parse_event() while (self._event is not None and not isinstance(self._event, pyyaml.SequenceEndEvent)): key = TextValue(str(len(node.children))) child_node = self._create_node(node) self._next_parse_event() if child_node is None: # i.e. unresolved alias continue child_node.key = key node.children.append(child_node) if self._event is not None: # update end_mark when array ends correctly end_mark = self._event.end_mark elif node.children: end_mark = node.children[-1].span.end end_mark.line -= 1 end_mark.column -= 1 node.span = Span.from_marks(start_mark, end_mark) return node