func (p *Lexer) Space() (int, byte) {
	n := 0
	m := 0
	for {
		c, _ := p.Byte()
		if c != '\t' && c != ' ' {
			break
		}
		if c == ' ' {
			n++
		} else {
			m++
		}
	}
	p.UnreadByte()
	var r byte
	if m == 0 {
		r = ' '
	} else if n == 0 {
		r = '\t'
	}
	return n + m, r
}
Space is (0x20|0x09)+. It returns a boolean indicating
if space has been found, and an integer indicating
how many spaces, iff uniform (either all 0x20 or 0x09)
package ogdl
import (
	"bytes"
	"errors"
	"io"
	"strconv"
	"unicode"
	"unicode/utf8"
)
const (
	bufSize  = 4096
	halfSize = 4096 / 2
)
var (
	errNegativeRead = errors.New("reader returned negative count from Read")
)
type Lexer struct {
	buf          []byte
	rd           io.Reader  
	r            int        
	lastByte     int        
	lastRuneSize []int      
	err          error
}
const maxConsecutiveEmptyReads = 100
func NewLexer(rd io.Reader) *Lexer {
	p := Lexer{}
	p.rd = rd
	p.lastByte = bufSize
	p.buf = make([]byte, bufSize)
	p.r = -1
	p.fill()
	return &p
}
func (p *Lexer) fill() {
	if p.r >= 0 && p.r < bufSize {
		return
	}
	offset := 0
	if p.r >= 0 {
		copy(p.buf, p.buf[halfSize:])
		p.r = halfSize
		offset = halfSize
	} else {
		p.r = 0
	}
	for i := maxConsecutiveEmptyReads; i > 0; i-- {
		n, err := p.rd.Read(p.buf[offset:])
		if n < 0 {
			panic(errNegativeRead)
		}
		if err != nil {
			p.err = err
			break
		}
		offset += n
		if offset >= halfSize {
			break
		}
	}
	p.lastByte = offset
}
func (p *Lexer) Error() error {
	err := p.err
	p.err = nil
	return err
}
func (p *Lexer) PeekByte() byte {
	c, err := p.Byte()
	if err != nil {
		return 0
	}
	p.UnreadByte()
	return c
}
func (p *Lexer) PeekRune() (rune, error) {
	r, err := p.Rune()
	if err != nil {
		return 0, nil
	}
	return r, p.UnreadRune()
}
func (p *Lexer) Byte() (byte, error) {
	if p.lastByte < bufSize && p.r >= p.lastByte {
		p.r = p.lastByte + 1
		return 0, ErrEOS
	}
	c := p.buf[p.r]
	p.r++
	p.fill()
	return c, nil
}
func (p *Lexer) UnreadByte() {
	if p.r <= 0 {
		return
	}
	p.r--
}
func (p *Lexer) Rune() (rune, error) {
	p.fill()
	r, size := rune(p.buf[p.r]), 1
	if r >= utf8.RuneSelf {
		r, size = utf8.DecodeRune(p.buf[p.r:p.lastByte])
	}
	p.r += size
	p.lastRuneSize = append(p.lastRuneSize, size)
	return r, nil
}
func (p *Lexer) UnreadRune() error {
	if len(p.lastRuneSize) == 0 {
		return ErrInvalidUnread
	}
	p.r -= p.lastRuneSize[len(p.lastRuneSize)-1]
	p.lastRuneSize = p.lastRuneSize[:len(p.lastRuneSize)-1]
	return nil
}
func (p *Lexer) String() (string, bool) {
	var buf []byte
	for {
		c, _ := p.Byte()
		if !IsTextChar(c) {
			break
		}
		buf = append(buf, c)
	}
	p.UnreadByte()
	return string(buf), len(buf) > 0
}
func (p *Lexer) StringStop(stopBytes []byte) (string, bool) {
	var buf []byte
	for {
		c, _ := p.Byte()
		if !IsTextChar(c) || bytes.IndexByte(stopBytes, c) != -1 {
			break
		}
		buf = append(buf, c)
	}
	p.UnreadByte()
	return string(buf), len(buf) > 0
}
func (p *Lexer) Break() bool {
	c, _ := p.Byte()
	if c == '\r' {
		c, _ = p.Byte()
	}
	if c == '\n' {
		return true
	}
	p.UnreadByte()
	return false
}
func (p *Lexer) End() bool {
	c, err := p.Byte()
	if err != nil {
		return true
	}
	if IsEndChar(c) {
		return true
	}
	p.UnreadByte()
	return false
}
func (p *Lexer) WhiteSpace() bool {
	any := false
	for {
		c, _ := p.Byte()
		if c != 13 && c != 10 && c != 9 && c != 32 {
			break
		}
		any = true
	}
	p.UnreadByte()
	return any
}