func NoneOf(rs ...rune) Parser {
	return &CharSetParser{allowed: rarray2rmap(rs), invert: true}
}
NoneOf returns a parser that parses a single occurrence of any rune
other than the ones given.
package parser
import (
	"bytes"
	"fmt"
	"github.com/jmikkola/parsego/parser/result"
	"github.com/jmikkola/parsego/parser/scanner"
	"github.com/jmikkola/parsego/parser/textpos"
)
type Parser interface {
	Parse(sc scanner.Scanner) result.ParseResult
}
func fail(at textpos.TextPos, format string, a ...interface{}) result.ParseResult {
	return result.Failed(textpos.Single(at), fmt.Errorf(format, a...))
}
type EOFParser struct{}
func EOF() Parser {
	return &EOFParser{}
}
func (p *EOFParser) Parse(sc scanner.Scanner) result.ParseResult {
	r, err := sc.Read()
	if err == nil {
		return fail(sc.GetPos(), "expected EOF, got %c", r)
	}
	return result.Success(textpos.Single(sc.GetPos()), "")
}
type CharRangeParser struct {
	min rune  
	max rune
}
func Char(c rune) Parser {
	return &CharRangeParser{c, c}
}
func CharRange(min, max rune) Parser {
	return &CharRangeParser{min, max}
}
func (p *CharRangeParser) Parse(sc scanner.Scanner) result.ParseResult {
	start := sc.GetPos()
	r, err := sc.Read()
	if err != nil {
		return fail(sc.GetPos(), "expected a character, got error %v", err)
	}
	if r < p.min || r > p.max {
		return fail(sc.GetPos(),
			"expected a character in the range '%c' to '%c', got error %c",
			p.min, p.max, r)
	}
	return result.Success(
		textpos.Range(start, sc.GetPos()),
		string(r))
}
type TokenParser struct {
	token string
}
func Token(token string) Parser {
	return &TokenParser{token}
}
func (p *TokenParser) Parse(sc scanner.Scanner) result.ParseResult {
	start := sc.GetPos()
	seen := []rune{}
	for _, c := range p.token {
		r, err := sc.Read()
		seen = append(seen, r)
		if err != nil {
			return fail(sc.GetPos(), "expected '%s', got error %v", p.token, err)
		}
		if r != c {
			return fail(sc.GetPos(), "expected '%s', got '%s'", p.token, string(seen))
		}
	}
	return result.Success(
		textpos.Range(start, sc.GetPos()),
		string(seen))
}
type CharSetParser struct {
	allowed map[rune]struct{}
	invert  bool
}
func AnyChar(rs ...rune) Parser {
	return &CharSetParser{allowed: rarray2rmap(rs), invert: false}
}