// Lexeme returns the bytes of the current selection.
546357
func (z *Lexer) Lexeme() []byte {
	return z.buf[z.start:z.pos]
}
855198
func (z *Lexer) Shift() []byte {
	b := z.buf[z.start:z.pos]
	z.start = z.pos
	return b
}
1071832
func (p *Parser) Lex(r io.Reader) ([]lexer.Token, error) {
	lex, err := p.lex.Lex(r)
	if err != nil {
		return nil, err
	}
	return lexer.ConsumeAll(lex)
}
760085
func LexWithScanner(r io.Reader, scan *scanner.Scanner) Lexer {
	return lexWithScanner(r, scan)
}
976160
func (l *Lexer) Lex() (tok Token, lit string) {
	switch ch := l.skipWhiteSpaces(l.read()); {
	case ch == 0:
		return EndOfStringToken, ""
	case isSpecialSymbol(ch):
		l.unread()
		return l.scanSpecialSymbol()
	default:
		l.unread()
		return l.scanIdOrKeyword()
	}
}
1286504
func lexFloat(lx *lexer) stateFn {
	r := lx.next()
	if isDigit(r) {
		return lexFloat
	}

	lx.backup()
	lx.emit(itemFloat)
	return lx.pop()
}
1355256
func (tkn *Tokenizer) Lex(lval *yySymType) int {
	if tkn.SkipToEnd {
		return tkn.skipStatement()
	}

	typ, val := tkn.Scan()
	for typ == COMMENT {
		if tkn.AllowComments {
			break
		}
		typ, val = tkn.Scan()
	}
	if typ == 0 || typ == ';' || typ == LEX_ERROR {
		// If encounter end of statement or invalid token,
		// we should not accept partially parsed DDLs. They
		// should instead result in parser errors. See the
		// Parse function to see how this is handled.
		tkn.partialDDL = nil
	}
	lval.bytes = val
	tkn.lastToken = val
	return typ
}
815192
func Lex(r io.Reader) Lexer {
	lexer := lexWithScanner(r, &scanner.Scanner{})
	lexer.scanner.Error = func(s *scanner.Scanner, msg string) {
		// This is to support single quoted strings. Hacky.
		if !strings.HasSuffix(msg, "char literal") {
			lexer.err = Errorf(Position(lexer.scanner.Pos()), msg)
		}
	}
	return lexer
}
726911
func lexQuotedKey(lx *lexer) stateFn {
	r := lx.peek()
	if r == sqStringEnd {
		lx.emit(itemKey)
		lx.next()
		return lexSkip(lx, lexKeyEnd)
	}
	lx.next()
	return lexQuotedKey
}
25997
func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, error) {
	var out []Token
	it, err := lexer.Tokenise(options, text)
	if err != nil {
		return nil, err
	}
	for t := it(); t != EOF; t = it() {
		out = append(out, t)
	}
	return out, nil
}
1001063
func (db *DB) LExpire(key []byte, duration int64) (int64, error) {
	if duration <= 0 {
		return 0, errExpireValue
	}

	return db.lExpireAt(key, time.Now().Unix()+duration)
}
1243742
func lexRightDelim(l *lexer) stateFn {
	if l.doubleDelim && l.next() != '}' {
		return l.errorf("expected double closing braces in tag")
	}
	l.emit(itemRightDelim)
	return lexText
}
397380
func (l *lexer) run() {
	for l.state = lexItem; l.state != nil; {
		l.state = l.state(l)
	}
}
897036
func lexString(lx *lexer) stateFn {
	r := lx.next()
	switch {
	case r == '\\':
		lx.addCurrentStringPart(1)
		return lexStringEscape
	// Termination of non-quoted strings
	case isNL(r) || r == eof || r == optValTerm ||
		r == arrayValTerm || r == arrayEnd || r == mapEnd ||
		isWhitespace(r):

		lx.backup()
		if lx.hasEscapedParts() {
			lx.emitString()
		} else if lx.isBool() {
			lx.emit(itemBool)
		} else if lx.isVariable() {
			lx.emit(itemVariable)
		} else {
			lx.emitString()
		}
		return lx.pop()
	case r == sqStringEnd:
		lx.backup()
		lx.emitString()
		lx.next()
		lx.ignore()
		return lx.pop()
	}
	return lexString
}
58088
func (l *lexer) lexUntilNewline() (string, int, int) {
	// Compute 'text'.
	var buf bytes.Buffer
	lastNonSpace := 0
	for r := l.next(); r != lexEOF && r != '\n'; r = l.next() {
		buf.WriteRune(r)
		if !isHorizontalWhitespace(r) {
			lastNonSpace = buf.Len()
		}
	}
	l.backup()
	// Trim whitespace off the end.
	buf.Truncate(lastNonSpace)
	text := buf.String()

	// Consume the '\n' and following indent.
	var newLines int
	newLines, indent := l.lexWhitespace()
	blanks := 0
	if newLines > 0 {
		blanks = newLines - 1
	}
	return text, blanks, indent
}
1058710
func lexMode(v []byte) lexModeValue {
	var (
		r      rune
		w      int
		offset int
	)

	for {
		r, w = utf8.DecodeRune(v[offset:])
		offset += w
		if unicode.IsSpace(r) {
			continue
		}
		if r == '{' {
			return lexModeJson
		}
		break
	}

	return lexModeHcl
}
461932
func lexEmoji(l *pageLexer) stateFunc {
	pos := l.pos + 1
	valid := false

	for i := pos; i < len(l.input); i++ {
		if i > pos && l.input[i] == emojiDelim {
			pos = i + 1
			valid = true
			break
		}
		r, _ := utf8.DecodeRune(l.input[i:])
		if !(isAlphaNumericOrHyphen(r) || r == '+') {
			break
		}
	}

	if valid {
		l.pos = pos
		l.emit(TypeEmoji)
	} else {
		l.pos++
		l.emit(tText)
	}

	return lexMainSection
}