func (p *Parser) error(err error) {
	p.errorf("%s", err)
}
error terminates processing.
package base
import (
	"encoding/json"
	"fmt"
	"gopkg.in/mgo.v2/bson"
	"math"
	"runtime"
	"strconv"
	"strings"
	"unicode/utf8"
	"github.com/johnwilson/bytengine"
)
type Parser struct {
	commands  []bytengine.Command
	cmdlookup map[string]map[string]interface{}
	registry  *FunctionRegistry
	lex       *lexer
	token     [2]item  
	peekCount int
}
type ServerFunction func(ctx string)
type UserFunction func(ctx string)
type DatabaseFunction func(db, ctx string)
func (p *Parser) next() item {
	if p.peekCount > 0 {
		p.peekCount--
	} else {
		p.token[0] = p.lex.nextItem()
	}
	return p.token[p.peekCount]
}
func (p *Parser) backup() {
	p.peekCount++
}
func (p *Parser) backup2(t1 item) {
	p.token[1] = t1
	p.peekCount = 2
}
func (p *Parser) peek() item {
	if p.peekCount > 0 {
		return p.token[p.peekCount-1]
	}
	p.peekCount = 1
	p.token[0] = p.lex.nextItem()
	return p.token[0]
}
func NewParser() *Parser {
	p := &Parser{}
	p.registry = NewFunctionRegistry()
	return p
}
func (p *Parser) errorf(format string, args ...interface{}) {
	p.commands = nil
	format = fmt.Sprintf("line[%d]: %s", p.lex.lineNumber(), format)
	panic(fmt.Errorf(format, args...))
}