func containerEnd(x *Lexer, it itemType) stateFn {
	if len(x.containers) == 0 {
		return x.error("unexpected closing of container")
	}

	switch ch := x.containers[len(x.containers)-1]; {
	case ch == '(' && it != IonSExpEnd:
		return x.errorf("expected closing of s-expression but found %s", it)
	case ch == '{' && it != IonStructEnd:
		return x.errorf("expected closing of struct but found %s", it)
	case ch == '[' && it != IonListEnd:
		return x.errorf("expected closing of list but found %s", it)
	}

	x.containers = x.containers[:len(x.containers)-1]
	x.emit(it)

	return lexValue
}
// containerEnd makes sure that the container being ended matches the last one
// opened.  It emits the given itemType if everything is fine.
containerEnd makes sure that the container being ended matches the last one
opened.  It emits the given itemType if everything is fine.
// containerEnd makes sure that the container being ended matches the last one // opened . It emits the given itemType if everything is fine .
func containerEnd(x *Lexer, it itemType) stateFn {
	if len(x.containers) == 0 {
		return x.error("unexpected closing of container")
	}
	switch ch := x.containers[len(x.containers)-1]; {
	case ch == '(' && it != IonSExpEnd:
		return x.errorf("expected closing of s-expression but found %s", it)
	case ch == '{' && it != IonStructEnd:
		return x.errorf("expected closing of struct but found %s", it)
	case ch == '[' && it != IonListEnd:
		return x.errorf("expected closing of list but found %s", it)
	}
	x.containers = x.containers[:len(x.containers)-1]
	x.emit(it)
	return lexValue
}
func containerEnd ( x * Lexer , it itemType ) stateFn { if len ( x . containers ) == 0 { return x . error ( " " ) } switch ch := x . containers [ len ( x . containers ) - 1 ] ; { case ch == '(' && it != IonSExpEnd : return x . errorf ( " " , it ) case ch == '{' && it != IonStructEnd : return x . errorf ( " " , it ) case ch == '[' && it != IonListEnd : return x . errorf ( " " , it ) } x . containers = x . containers [ : len ( x . containers ) - 1 ] x . emit ( it ) return lexValue }
containerEnd makes sure that the container being ended matches the last one
opened.
containerEnd makes sure that the container being ended matches the last one opened .