'Handle given value based on state of parser
This method handles the various values that are created by the builder
at the beginning of scope events (such as mappings and sequences) or
when a scalar value is received.
Method is called when handler receives a parser, MappingStart or
SequenceStart.
Args:
value: Value received as scalar value or newly constructed mapping or
sequence instance.
Raises:
InternalError if the building process encounters an unexpected token.
This is an indication of an implementation error in BuilderHandler.'

def _HandleValue(self, value):

    (token, top_value) = self._top
    if (token == _TOKEN_KEY):
        key = self._Pop()
        (mapping_token, mapping) = self._top
        assert (_TOKEN_MAPPING == mapping_token)
        self._builder.MapTo(mapping, key, value)
    elif (token == _TOKEN_MAPPING):
        self._Push(_TOKEN_KEY, value)
    elif (token == _TOKEN_SEQUENCE):
        self._builder.AppendTo(top_value, value)
    elif (token == _TOKEN_DOCUMENT):
        self._builder.InitializeDocument(top_value, value)
    else:
        raise yaml_errors.InternalError(('Unrecognized    builder    token:\n%s' % token))
