// lexString scans a string
774321
func lexString(l *Lexer) lexFunc {
	// get string delimiter
	delim := l.next()
	var prev rune

	// ignore delimiter
	l.ignore()

	for {
		r := l.next()
		if r == eof || r == '\n' {
			return l.errorf("Unterminated string")
		}

		if (r == delim) && (prev != '\\') {
			break
		}

		prev = r
	}

	// remove end delimiter
	l.backup()

	// emit string
	l.emitString(delim)

	// skip end delimiter
	l.next()
	l.ignore()

	return lexExpression
}
71249
func lexChar(l *lexer) stateFn {
Loop:
	for {
		switch l.next() {
		case '\\':
			if r := l.next(); r != eof && r != '\n' {
				break
			}
			fallthrough
		case eof, '\n':
			return l.errorf("unterminated character constant")
		case '\'':
			break Loop
		}
	}
	l.emit(itemCharConstant)
	return lexInsideAction
}
962572
func lexExpr(name, input string) *lexer {
	l := &lexer{
		name:  name,
		input: input,
		items: make(chan item),
		state: lexInsideTag,
	}
	go l.run()
	return l
}
563360
func (z *StreamLexer) Lexeme() []byte {
	return z.buf[z.start:z.pos]
}
384590
func (r *Lexer) String() string {
	if r.token.kind == tokenUndef && r.Ok() {
		r.FetchToken()
	}
	if !r.Ok() || r.token.kind != tokenString {
		r.errInvalidToken("string")
		return ""
	}
	ret := string(r.token.byteValue)
	r.consume()
	return ret
}
760085
func LexWithScanner(r io.Reader, scan *scanner.Scanner) Lexer {
	return lexWithScanner(r, scan)
}
658598
func (r *Resp) ToString() (string, error) {
	data, err := r.ToBytes()
	return string(data), err
}
1263478
func (s *ValidateService) BodyString(body string) *ValidateService {
	s.bodyString = body
	return s
}
580624
func lex(name, input string, run bool) *lexer {
	l := &lexer{
		name:       name,
		input:      input,
		items:      make(chan item),
		leftDelim:  defaultLeftDelim,
		rightDelim: defaultRightDelim,
	}
	if run {
		l.run()
	}
	return l
}
690331
func lexQuotedString(lx *lexer) stateFn {
	r := lx.next()
	switch {
	case r == sqStringEnd:
		lx.backup()
		lx.emit(itemString)
		lx.next()
		lx.ignore()
		return lx.pop()
	}
	return lexQuotedString
}
1169744
func lexToken(l *lexer) stateFn {
	for {
		{
			r := l.peek()
			switch r {
			case binding:
				l.next()
				return lexBinding
			case slash:
				return lexNode
			case underscore:
				l.next()
				return lexBlankNode
			case quote:
				return lexPredicateOrLiteral
			}
			if unicode.IsLetter(r) {
				return lexKeyword
			}
		}
		if state := isSingleSymbolToken(l, ItemLBracket, leftBracket); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemRBracket, rightBracket); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemLPar, leftPar); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemRPar, rightPar); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemSemicolon, semicolon); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemDot, dot); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemComma, comma); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemLT, lt); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemGT, gt); state != nil {
			return state
		}
		if state := isSingleSymbolToken(l, ItemEQ, eq); state != nil {
			return state
		}
		{
			r := l.next()
			if unicode.IsSpace(r) {
				l.ignore()
				continue
			}
			if l.next() == eof {
				break
			}
		}
	}
	l.emit(ItemEOF) // Useful to make EOF a token.
	return nil      // Stop the run loop.
}
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)
}
1128010
func lexPathLiteral(l *Lexer) lexFunc {
	for {
		r := l.next()
		if r == eof || r == '\n' {
			return l.errorf("Unterminated path literal")
		}

		if r == ']' {
			break
		}
	}

	l.emit(TokenID)

	return lexExpression
}
1127414
func lex(input string, capacity int) (*lexer, <-chan Token) {
	l := &lexer{
		input:  input,
		tokens: make(chan Token, capacity),
	}
	go l.run() // Concurrently run state machine.
	return l, l.tokens
}
446963
func lexStringEscape(lx *lexer) stateFn {
	r := lx.next()
	switch r {
	case 'x':
		return lexStringBinary
	case 't':
		return lx.addStringPart("\t")
	case 'n':
		return lx.addStringPart("\n")
	case 'r':
		return lx.addStringPart("\r")
	case '"':
		return lx.addStringPart("\"")
	case '\\':
		return lx.addStringPart("\\")
	}
	return lx.errorf("Invalid escape character '%v'. Only the following "+
		"escape characters are allowed: \\xXX, \\t, \\n, \\r, \\\", \\\\.", r)
}
356086
func (l *Lexer) consumeString() TokenType {
	// assume to be on " or '
	delim := l.r.Peek(0)
	l.r.Move(1)
	for {
		c := l.r.Peek(0)
		if c == 0 && l.r.Err() != nil {
			break
		} else if c == '\n' || c == '\r' || c == '\f' {
			l.r.Move(1)
			return BadStringToken
		} else if c == delim {
			l.r.Move(1)
			break
		} else if c == '\\' {
			if !l.consumeEscape() {
				l.r.Move(1)
				l.consumeNewline()
			}
		} else {
			l.r.Move(1)
		}
	}
	return StringToken
}
602656
func OptString(l *State, index int, def string) string {
	if l.IsNoneOrNil(index) {
		return def
	}
	return CheckString(l, index)
}