// consume attempts to consume all input tokens for the provided symbols given
// the parser grammar.
180148
func (p *Parser) consume(llk *LLk, st *semantic.Statement, s semantic.Symbol) (bool, error) {
	for _, clause := range (*p.grammar)[s] {
		if len(clause.Elements) == 0 {
			return true, nil
		}
		elem := clause.Elements[0]
		if elem.isSymbol {
			return false, fmt.Errorf("Parser.consume: not left factored grammar in %v", clause)
		}
		if llk.CanAccept(elem.Token()) {
			return p.expect(llk, st, s, clause)
		}
	}
	return false, fmt.Errorf("Parser.consume: could not consume token %s in production %s", llk.Current(), s)
}
463631
func (g *globTokeniser) parse(lastTokenType tc) (string, tc, error) {
	var err error

	tokenBuf := new(bytes.Buffer)
	tokenType := tcUnknown
	escaped := lastTokenType == tcEscaper

	for {
		var r rune
		r, _, err = g.input.ReadRune()
		if err != nil {
			break
		}

		runeType := tcUnknown
		switch r {
		case Escaper:
			runeType = tcEscaper
		case '*':
			if tokenType == tcStar {
				runeType = tcGlobStar
				tokenType = tcGlobStar
			} else {
				runeType = tcStar
			}
		case '?':
			runeType = tcAny
		case g.globOptions.Separator:
			runeType = tcSeparator
		default:
			runeType = tcLiteral
		}

		if escaped {
			// If the last token was an Escaper, this MUST be a literal
			runeType = tcLiteral
			escaped = false
		}

		if (tokenType != tcUnknown) && (tokenType != runeType) {
			// We've stumbled into the next token; backtrack
			g.input.UnreadRune()
			break
		}

		tokenType = runeType
		tokenBuf.WriteRune(r)

		if tokenType == tcEscaper ||
			tokenType == tcGlobStar ||
			tokenType == tcAny ||
			tokenType == tcSeparator {
			// These tokens are standalone; continued consumption must be a separate token
			break
		}
	}

	if err == io.EOF && tokenType != tcUnknown {
		// If we have a token, we can't have an EOF: we want the EOF on the next pass
		err = nil
	}

	if err != nil {
		return "", tcUnknown, err
	}

	if tokenType == tcEscaper {
		// Escapers should never be yielded; recurse to find the next token
		return g.parse(tokenType)
	}

	return tokenBuf.String(), tokenType, err
}
76571
func (l *Lexer) consumeComment() {
	if l.next != '#' {
		panic("consumeComment used in wrong context")
	}

	// TODO: count and trim whitespace so we can dedent any following lines.
	if l.sc.Peek() == ' ' {
		l.sc.Next()
	}

	if l.descComment != "" && !l.useStringDescriptions {
		// TODO: use a bytes.Buffer or strings.Builder instead of this.
		l.descComment += "\n"
	}

	for {
		next := l.sc.Next()
		if next == '\r' || next == '\n' || next == scanner.EOF {
			break
		}

		if !l.useStringDescriptions {
			// TODO: use a bytes.Buffer or strings.Build instead of this.
			l.descComment += string(next)
		}
	}
}
285373
func (cons *SystemdConsumer) Consume(workers *sync.WaitGroup) {
	cons.AddMainWorker(workers)
	go cons.read()
	cons.ControlLoop()
}
564437
func (l *lexer) load(input io.Reader) error {
	l.reader = bufio.NewReader(input)
	l.line = 1

	// discard byte order mark, if present
	firstCh, _, err := l.reader.ReadRune()
	if err != nil {
		return err
	}
	if firstCh != 0xFEFF {
		err := l.reader.UnreadRune()
		if err != nil {
			return err
		}
	}

	return nil
}
748496
func (t *Iterator) Consume(cnt int) {
	for i := 0; i < cnt; i++ {
		token := t.Next()
		if token.Type == tError || token.Type == tEOF {
			t.Backup()
			break
		}
	}
}
234218
func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder {
	b.consumes = mimeTypes
	return b
}
209211
func (p *unvisParser) Peek() (rune, error) {
	if p.idx >= len(p.tokens) {
		return unicode.ReplacementChar, fmt.Errorf("tried to read past end of token list")
	}
	return p.tokens[p.idx], nil
}
25435
func (consumer *googlePubSubConsumer) Consume() (chan Message, error) {
	channel := make(chan Message)

	go func() {
		cctx, _ := context.WithTimeout(context.Background(), ContextDuration)

		err := consumer.Subscription.Receive(cctx,
			func(ctx context.Context, msg *pubsub.Message) {
				wrappedMsg := &googlePubSubMessage{OriginalMessage: msg}
				channel <- wrappedMsg
			})

		if err != nil {
			log.Fatalf("Could not receive message from subscription: %v", err)
		}
	}()

	return channel, nil
}
1259147
func (b *Buffer) consume(n int) ([]byte, bool) {
	if !b.Has(n) {
		return nil, false
	}
	rval := b.data[:n]
	b.data = b.data[n:]
	return rval, true
}
530661
func Consume(shardID string, streamName string, region string, shardIteratorType string, eventChannel chan []byte) {
	svc := kinesis.New(session.New(), &aws.Config{Region: aws.String(region)})
	getShardIteratorParams := &kinesis.GetShardIteratorInput{
		ShardId:           aws.String(shardID),           // Required
		ShardIteratorType: aws.String(shardIteratorType), // Required
		StreamName:        aws.String(streamName),        // Required
	}
	shardIterator, err := svc.GetShardIterator(getShardIteratorParams)
	if err != nil {
		log.Panic(err)
	}

	nextShardIterator := shardIterator.ShardIterator
	for {
		getRecordsParams := &kinesis.GetRecordsInput{
			ShardIterator: nextShardIterator, // Required
			Limit:         aws.Int64(1000),
		}
		getRecordsResp, err := svc.GetRecords(getRecordsParams)
		if err != nil {
			log.Panic(err)
		}
		for _, record := range getRecordsResp.Records {
			eventChannel <- record.Data
		}
		nextShardIterator = getRecordsResp.NextShardIterator
		time.Sleep(time.Second)
	}
}
363089
func (cons *AwsKinesis) Consume(workers *sync.WaitGroup) {
	cons.AddMainWorker(workers)
	defer cons.close()

	if err := cons.connect(); err != nil {
		cons.Logger.Error("Connection error: ", err)
	} else {
		cons.ControlLoop()
	}
}
36607
func (c *Client) Consume(consume bool) error {
	if consume {
		return c.Command("consume 1").OK()
	}
	return c.Command("consume 0").OK()
}
150503
func (l *Lexer) consumeByte(c byte) bool {
	if l.r.Peek(0) == c {
		l.r.Move(1)
		return true
	}
	return false
}
584077
func (w *Wildmatch) consume(t string, opt MatchOpts) ([]string, bool) {
	if w.basename {
		// If the receiving Wildmatch has basename set, the pattern
		// matches only the basename of the given "t".
		t = filepath.Base(t)
	}

	if w.caseFold {
		// If the receiving Wildmatch is case insensitive, the pattern
		// "w.p" will be lower-case.
		//
		// To preserve insensitivity, lower the given path "t", as well.
		t = strings.ToLower(t)
	}

	var isDir bool
	if opt.IsDirectory {
		isDir = true
		// Standardize the formation of subject string so directories always
		// end with '/'
		if !strings.HasSuffix(t, "/") {
			t = t + "/"
		}
	} else {
		isDir = strings.HasSuffix(t, string(sep))
	}

	dirs := strings.Split(t, string(sep))

	// Git-attribute style matching can never match a directory
	if w.gitattributes && isDir {
		return dirs, false
	}

	// Match each directory token-wise, allowing each token to consume more
	// than one directory in the case of the '**' pattern.
	for _, tok := range w.ts {
		var ok bool

		dirs, ok = tok.Consume(dirs, isDir)
		if !ok {
			// If a pattern could not match the remainder of the
			// filepath, return so immediately, along with the paths
			// that we did successfully manage to match.
			return dirs, false
		}
	}
	return dirs, true
}
214703
func (cons *LogConsumer) Consume(threads *sync.WaitGroup) {
	// Wait for control statements
	for {
		select {
		case msg := <-cons.queue:
			cons.logRouter.Enqueue(msg)

		case command := <-cons.control:
			if command == PluginControlStopConsumer {
				cons.queue.Close()
				for msg := range cons.queue {
					cons.logRouter.Enqueue(msg)
				}
				cons.stopped = true
				return // ### return ###
			}
		}
	}
}
1363370
func (c *requestCache) Consume(token string) (req request, found bool) {
	c.lock.Lock()
	defer c.lock.Unlock()
	ele, ok := c.tokens[token]
	if !ok {
		return nil, false
	}
	c.ll.Remove(ele)
	delete(c.tokens, token)

	entry := ele.Value.(*cacheEntry)
	if c.clock.Now().After(entry.expireTime) {
		// Entry already expired.
		return nil, false
	}
	return entry.req, true
}