func NewParser(r io.Reader, defaultURI, defaultToken string, lineHeader int, queryRange string, samplersCount string, variableList []string) (*Parser, error) {
	hasQueryRange := false
	parserQueryRange := &QueryRange{}
	if queryRange != "" {
		err := parserQueryRange.queryRangeParser(queryRange)
		if err != nil {
			return nil, err
		}
		hasQueryRange = true
	}
	lit := "100"
	if samplersCount != "" {
		var tok Token
		scanner := newBufScanner(strings.NewReader(string(samplersCount)))
		tok, _, lit = scanner.Scan()
		if tok != INTEGER {
			return nil, fmt.Errorf("Error in header %q, expects an Integer number", samplersCountHeader)
		}
	}
	variables := make(map[string]*Variable)
	for _, variable := range variableList {
		variables[variable] = &Variable{name: variable, tokenType: NATIVEVARIABLE, lit: variable}
	}
	return &Parser{s: newBufScanner(r), variables: variables, defaultURI: defaultURI, defaultToken: defaultToken, lineStart: lineHeader,
		hasQueryRange: hasQueryRange, queryRange: parserQueryRange, samplersCount: lit}, nil
}
NewParser returns a new instance of Parser
package tsl
import (
	"encoding/base64"
	"fmt"
	"io"
	"regexp"
	"strconv"
	"strings"
	"time"
	log "github.com/sirupsen/logrus"
)
const (
	lineStartHeader     = "TSL-Line-Start"
	queryRandeHeader    = "TSL-Query-Range"
	samplersCountHeader = "TSL-Samplers"
)
var reZeroOnly = regexp.MustCompile(`^\s*0+\s*$`)
type ProtoParser struct {
	LineStart int     
	Name      string  
}
type Parser struct {
	s             *bufScanner
	variables     map[string]*Variable
	lineStart     int
	defaultURI    string
	defaultToken  string
	samplersCount string
	hasQueryRange bool
	queryRange    *QueryRange
}
type QueryRange struct {
	defaultIsLast       bool
	defaultLastDuration string
	defaultFromStart    InternalField
	defaultFromTo       InternalField
}