// NewTokenBuffer returns a new TokenBuffer.
430193
func NewTokenBuffer(l *html.Lexer) *TokenBuffer {
	return &TokenBuffer{
		l:   l,
		buf: make([]Token, 0, 8),
	}
}
608015
func (b *PositionBuilder) NewTokensPosition(startToken *scanner.Token, endToken *scanner.Token) *position.Position {
	return &position.Position{
		StartLine: startToken.StartLine,
		EndLine:   endToken.EndLine,
		StartPos:  startToken.StartPos,
		EndPos:    endToken.EndPos,
	}
}
905808
func newTokenCache(cfg tokenCacheConfig) *tokenCache {
	return &tokenCache{
		cfg: cfg,
		lc: layered.Cache{
			ProcessLRUCache: cfg.ProcessLRUCache,
			GlobalNamespace: globalCacheNamespace,
			Marshal:         json.Marshal, // marshals *cachedToken
			Unmarshal: func(blob []byte) (interface{}, error) {
				out := &cachedToken{}
				err := json.Unmarshal(blob, out)
				return out, err
			},
		},
	}
}
1201287
func (dl *dialLimiter) freeFDToken() {
	log.Debugf("[limiter] freeing FD token; waiting: %d; consuming: %d", len(dl.waitingOnFd), dl.fdConsuming)
	dl.fdConsuming--

	for len(dl.waitingOnFd) > 0 {
		next := dl.waitingOnFd[0]
		dl.waitingOnFd[0] = nil // clear out memory
		dl.waitingOnFd = dl.waitingOnFd[1:]

		if len(dl.waitingOnFd) == 0 {
			// clear out memory.
			dl.waitingOnFd = nil
		}

		// Skip over canceled dials instead of queuing up a goroutine.
		if next.cancelled() {
			dl.freePeerToken(next)
			continue
		}
		dl.fdConsuming++

		// we already have activePerPeer token at this point so we can just dial
		go dl.executeDial(next)
		return
	}
}
1142654
func (bot *TgBot) NewTitleChatFn(f func(TgBot, Message, int, string)) *TgBot {
	bot.addToConditionalFuncs(NewTitleConditionalCall{f})
	return bot
}
532450
func (p *parser) parseImpliedToken(t TokenType, dataAtom a.Atom, data string) {
	realToken, selfClosing := p.tok, p.hasSelfClosingToken
	p.tok = Token{
		Type:     t,
		DataAtom: dataAtom,
		Data:     data,
	}
	p.hasSelfClosingToken = false
	p.parseCurrentToken()
	p.tok, p.hasSelfClosingToken = realToken, selfClosing
}
1193399
func ParseExprWithFuncs(p TokenPager, fr FuncResolver) (Node, error) {
	t := newTreeFuncs(p, fr)
	// Parser panics on unexpected syntax, convert this into an err
	return t.parse()
}
392072
func NewTokenGroupAdder(auth authenticator.Token, groups []string) authenticator.Token {
	return &TokenGroupAdder{auth, groups}
}
499145
func (s *AccessTokenSession) TokenFunc(retried bool) (string, error) {
	if !s.token.IsValid() || retried {
		refreshToken, refreshable := s.token.(RefreshableAccessToken)
		if !refreshable {
			return "", errors.New("not a refresh token")
		}

		tokenResp, err := s.uaa.RefreshTokenGrant(refreshToken.RefreshValue())
		if err != nil {
			return "", bosherr.WrapError(err, "refreshing token")
		}

		s.token = tokenResp
		if err = s.saveTokenCreds(); err != nil {
			return "", err
		}
	}

	return s.token.Type() + " " + s.token.Value(), nil
}
490123
func (e *encodeState) newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc {
	if t.Implements(marshalerType) {
		return marshalerEncoder
	}
	if t.Kind() != reflect.Ptr && allowAddr {
		if reflect.PtrTo(t).Implements(marshalerType) {
			return newCondAddrEncoder(addrMarshalerEncoder, e.newTypeEncoder(t, false))
		}
	}

	if t.Implements(textMarshalerType) {
		return textMarshalerEncoder
	}
	if t.Kind() != reflect.Ptr && allowAddr {
		if reflect.PtrTo(t).Implements(textMarshalerType) {
			return newCondAddrEncoder(addrTextMarshalerEncoder, e.newTypeEncoder(t, false))
		}
	}

	switch t.Kind() {
	case reflect.Bool:
		return boolEncoder
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return intEncoder
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return uintEncoder
	case reflect.Float32:
		return float32Encoder
	case reflect.Float64:
		return float64Encoder
	case reflect.String:
		return stringEncoder
	case reflect.Interface:
		return interfaceEncoder
	case reflect.Struct:
		return e.newStructEncoder(t)
	case reflect.Map:
		return e.newMapEncoder(t)
	case reflect.Slice:
		return e.newSliceEncoder(t)
	case reflect.Array:
		return e.newArrayEncoder(t)
	case reflect.Ptr:
		return e.newPtrEncoder(t)
	default:
		return unsupportedTypeEncoder
	}
}
749279
func NewConsumedToken(tkn *lexer.Token) ConsumedElement {
	return ConsumedElement{
		isSymbol: false,
		token:    tkn,
	}
}
577367
func (s *DefaultCookieProtector) NewToken(data []byte) ([]byte, error) {
	nonce := make([]byte, cookieNonceSize)
	if _, err := rand.Read(nonce); err != nil {
		return nil, err
	}
	aead, aeadNonce, err := s.createAEAD(nonce)
	if err != nil {
		return nil, err
	}
	return append(nonce, aead.Seal(nil, aeadNonce, data, nil)...), nil
}
323891
func (s *Statement) LitRuneFunc(f func() rune) *Statement {
	t := token{
		typ:     literalRuneToken,
		content: f(),
	}
	*s = append(*s, t)
	return s
}
488751
func NewTokenVerification(response *http.Response) (*TokenVerification, error) {
	tokenVerification := &TokenVerification{HTTPResponse: response}
	body, err := ioutil.ReadAll(response.Body)

	if err != nil {
		Logger.Println("Error reading from API:", err)
		return tokenVerification, err
	}

	err = json.Unmarshal(body, &tokenVerification)
	if err != nil {
		Logger.Println("Error parsing JSON:", err)
		return tokenVerification, err
	}

	return tokenVerification, nil
}
297914
func NewTypeBasedAnnotation(s *Storage, p PunctStrings, e TokenExistential) *TypeBasedAnnotation {
	return &TypeBasedAnnotation{
		Storage:          s,
		PunctStrings:     p,
		TokenExistential: e,
	}
}
698868
func NewTokenGenerator(s string, err error) TokenGenerator {
	return TokenGenerator{
		TokenFn: func() (string, error) {
			return s, err
		},
	}
}
349632
func newTokenSinceNow(user string, dur time.Duration, secret []byte) string {
	return newToken(user, time.Now().Add(dur), secret)
}