func PPrintStream(dst io.Writer, src io.Reader, opt *PPrintOpts) error {
	var lex lexer
	var col, prevCollStart, curSize int
	var prevColl bool
	lex.reset()
	tokStack := newTokenStack()
	shift := make([]int, 1, 8)  
	curType := tokenError
	d := NewDecoder(src)
	for {
		bs, tt, err := d.nextToken()
		if err != nil {
			return err
		}
		err = tokStack.push(tt)
		if err != nil {
			return err
		}
		prevType := curType
		prevSize := curSize
		if len(tokStack.toks) > 0 {
			curType = tokStack.peek()
			curSize = tokStack.peekCount()
		}
		switch tt {
		case tokenVectorEnd, tokenListEnd, tokenMapEnd:
		default:
			switch prevType {
			case tokenMapStart:
				if prevSize%2 == 0 && prevSize > 0 {
					dst.Write(commaOutputBytes)
					pprintIndent(dst, shift[len(shift)-1])
					col = shift[len(shift)-1]
				} else if prevSize%2 == 1 {  
					dst.Write(spaceOutputBytes)
					col++
				}
			case tokenSetStart, tokenVectorStart, tokenListStart:
				if prevColl {
					pprintIndent(dst, prevCollStart)
					col = prevCollStart
				} else if prevSize > 0 {
					dst.Write(spaceOutputBytes)
					col++
				}
			}
		}
		switch tt {
		case tokenMapStart, tokenVectorStart, tokenListStart, tokenSetStart:
			dst.Write(bs)
			col += len(bs)              
			shift = append(shift, col)  
		case tokenVectorEnd, tokenListEnd, tokenMapEnd:  
			dst.Write(bs)  
			prevCollStart = shift[len(shift)-1] - 1
			shift = shift[:len(shift)-1]
		case tokenTag:
			bslen := utf8.RuneCount(bs)
			dst.Write(bs)
			dst.Write(spaceOutputBytes)
			col += bslen + 1
		default:
			bslen := utf8.RuneCount(bs)
			dst.Write(bs)
			col += bslen
		}
		prevColl = (tt == tokenMapEnd || tt == tokenVectorEnd || tt == tokenListEnd)
		if tokStack.done() {
			break
		}
	}
	return nil
}
PPrintStream is an implementation of PPrint for generic readers and writers
package edn
import (
	"bytes"
	"io"
	"unicode/utf8"
)
var (
	spaceOutputBytes = []byte(" ")
	commaOutputBytes = []byte(",")
)
func newline(dst io.Writer, prefix, indent string, depth int) {
	dst.Write([]byte{'\n'})
	dst.Write([]byte(prefix))
	for i := 0; i < depth; i++ {
		dst.Write([]byte(indent))
	}
}
func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
	origLen := dst.Len()
	err := IndentStream(dst, bytes.NewBuffer(src), prefix, indent)
	if err != nil {
		dst.Truncate(origLen)
	}
	return err
}
func IndentStream(dst io.Writer, src io.Reader, prefix, indent string) error {
	var lex lexer
	lex.reset()
	tokStack := newTokenStack()
	curType := tokenError
	curSize := 0
	d := NewDecoder(src)
	depth := 0
	for {
		bs, tt, err := d.nextToken()
		if err != nil {
			return err
		}
		err = tokStack.push(tt)
		if err != nil {
			return err
		}
		prevType := curType
		prevSize := curSize
		if len(tokStack.toks) > 0 {
			curType = tokStack.peek()
			curSize = tokStack.peekCount()
		}
		switch tt {
		case tokenMapStart, tokenVectorStart, tokenListStart, tokenSetStart:
			if prevType == tokenMapStart {
				dst.Write([]byte{' '})
			} else if depth > 0 {
				newline(dst, prefix, indent, depth)
			}
			dst.Write(bs)
			depth++
		case tokenVectorEnd, tokenListEnd, tokenMapEnd:  
			depth--
			if prevSize > 0 {  
				newline(dst, prefix, indent, depth)
			}
			dst.Write(bs)
		case tokenTag:
			switch prevType {
			case tokenMapStart:
				if prevSize%2 == 0 {  
					if prevSize > 0 {
						dst.Write(commaOutputBytes)
					}
					newline(dst, prefix, indent, depth)
				} else {  
					dst.Write(spaceOutputBytes)
				}
				dst.Write(bs)
				dst.Write(spaceOutputBytes)
			case tokenSetStart, tokenVectorStart, tokenListStart:
				newline(dst, prefix, indent, depth)
				dst.Write(bs)
				dst.Write(spaceOutputBytes)
			default:  
				dst.Write(bs)
				dst.Write(spaceOutputBytes)
			}
		default:
			switch prevType {
			case tokenMapStart:
				if prevSize%2 == 0 {  
					if prevSize > 0 {
						dst.Write(commaOutputBytes)
					}
					newline(dst, prefix, indent, depth)
				} else {  
					dst.Write(spaceOutputBytes)
				}
				dst.Write(bs)
			case tokenSetStart, tokenVectorStart, tokenListStart:
				newline(dst, prefix, indent, depth)
				dst.Write(bs)
			default:  
				dst.Write(bs)
			}
		}
		if tokStack.done() {
			break
		}
	}
	return nil
}
type PPrintOpts struct {
	RightMargin int
	MiserWidth  int
}
func pprintIndent(dst io.Writer, shift int) {
	spaces := make([]byte, shift+1)
	spaces[0] = '\n'
	for i := 1; i <= shift; i++ {
		spaces[i] = ' '
	}
	dst.Write(spaces)
}
func PPrint(dst *bytes.Buffer, src []byte, opt *PPrintOpts) error {
	origLen := dst.Len()
	err := PPrintStream(dst, bytes.NewBuffer(src), opt)
	if err != nil {
		dst.Truncate(origLen)
	}
	return err
}