func (d *driver) Bytes() []byte {
	return d.s.Bytes()
}
Bytes implements rules.ScanState for tableLexer/driver.
package lexer
import (
	"bytes"
	"fmt"
	"io"
	"reflect"
	"strings"
	"unicode/utf8"
	"github.com/alecthomas/participle/lexer"
	"github.com/kythe/llvmbzlgen/cmakelib/lexer/rules"
)
const (
	initialCondition rules.StartCondition = rules.InitialCondition + iota
	commentCondition
	bracketCondition
	bracketEndCondition
	stringCondition
)
var (
	makeVarPattern  = `\$\([A-Za-z0-9_]*\)`
	unquotedPattern = `([^ \0\t\r\n()#\\"[=]|\\[^\0\n])`
	legacyPattern   = fmt.Sprintf(`(%s|%s|"(%s|%s|[ \t[=])*")`, makeVarPattern, unquotedPattern, makeVarPattern, unquotedPattern)
)
// fileTable contains the Rules table for lexing CMakeLists.txt files.
var fileTable = rules.New(
	rules.ExclusiveConditions(
		commentCondition,
		bracketCondition,
		bracketEndCondition,
		stringCondition,
	),
	rules.In(rules.InitialCondition, commentCondition).Match(`\n`, lexNewline),
	rules.In().Match(`#?\[=*\[\n?`, lexBracketOpen),
	rules.In().Match(`#`, lexCommentStart),
	rules.In(commentCondition).Match(`[^\0\n]*`, lexComment),
	rules.In().Match(`[()]`, lexParen),
	rules.In().Match(`[A-Zaa-z_][A-Za-z0-9_]*`, lexIdentifier),
	rules.In(bracketCondition).Match(`\]=*`, lexBracketTail),
	rules.In(bracketEndCondition).Match(`\]`, lexBracketClose),
	rules.In(bracketCondition).Match(`([^]\0\n])+`, lexBracketContent),
	rules.In(bracketCondition, bracketEndCondition).Match(`\n`, lexBracketReset),
	rules.In(bracketCondition, bracketEndCondition).Match(`[^\0\n]`, lexBracketReset),
	rules.In(bracketCondition, bracketEndCondition).Match(rules.EOFPattern, lexBracketEOF),
	rules.In().Match(fmt.Sprintf(`(%s|=|\[=*%s)(%s|[[=])*`, unquotedPattern, unquotedPattern, unquotedPattern), lexUnquoted),
	rules.In().Match(fmt.Sprintf(`(%s|%s|=|\[=*%s)(%s|[[=])*`, makeVarPattern, unquotedPattern, legacyPattern, legacyPattern), lexUnquoted),
	rules.In().Match(`\[`, lexUnquoted),
	rules.In().Match(`"`, lexOpenQuote),
	rules.In(stringCondition).Match(`([^\\\0\n"]|\\[^\0\n])+`, lexQuoted),
	rules.In(stringCondition).Match(`\\\n`, lexContinuation),
	rules.In(stringCondition).Match(`\n`, lexQuoted),
	rules.In(stringCondition).Match(`"`, lexEndQuote),
	rules.In(stringCondition).Match(`[^\0\n]`, lexQuoted),
	rules.In(stringCondition).Match(rules.EOFPattern, lexQuotedEOF),
	rules.In().Match(`[ \t\r]+`, lexSpace),
	rules.In().Match(`.`, lexUnexpected),
	rules.In().Match(rules.EOFPattern, lexEOF),
)
var argTable = rules.New(
	rules.In().Match(`\$ENV\{`, lexEnvOpen),
	rules.In().Match(`\$[A-Za-z0-9_.+-]*\{`, lexVarOpen),
	rules.In().Match(`}`, lexVarClose),
	rules.In().Match(`\\.`, lexEscapeSequence),
	rules.In().Match(`[^$\\}]+`, lexArgument),
	rules.In().Match(`.`, lexArgument),
	rules.In().Match(rules.EOFPattern, lexEOF),
)
type tableLexer struct {
	s *rules.Scanner
	buf []lexer.Token
	bracket int          
	base    lexer.Token  
}
type driver tableLexer
type splitLexer struct {
	file lexer.Lexer
	arg  lexer.Lexer
}
func (s *splitLexer) Next() (lexer.Token, error) {
	if s.arg != nil {
		if next, err := s.arg.Next(); !(err == nil && next.Type == lexer.EOF) {
			return next, err
		}
		s.arg = nil
	}
	next, err := s.file.Next()
	if err != nil {
		return next, err
	}
	switch next.Type {
	case Quoted, Unquoted:
		arg := newArgumentLexer(next)
		if succ, err := arg.Next(); err != nil || (succ.Type != lexer.EOF && !reflect.DeepEqual(succ, next)) {
			s.arg = arg
			return succ, err
		}
	}
	return next, err
}
func newFileLexer(r io.Reader) *tableLexer {
	return &tableLexer{
		rules.NewScanner(fileTable, r),
		nil,
		-1,
		lexer.Token{},
	}
}
func newArgumentLexer(base lexer.Token) *tableLexer {
	l := &tableLexer{
		rules.NewScanner(argTable, strings.NewReader(base.Value)),
		nil,
		-1,
		base,
	}
	l.s.SetPosition(base.Pos)
	return l
}
func newSplitLexer(r io.Reader) *splitLexer {
	return &splitLexer{newFileLexer(r), nil}
}
func (l *tableLexer) Next() (lexer.Token, error) {
	for {
		if len(l.buf) > 0 {
			tok := l.buf[0]
			l.buf = l.buf[1:]
			return tok, nil
		}
		if err := l.advance(); err != nil {
			return lexer.EOFToken(l.s.Pos()), err
		}
	}
}
func (l *tableLexer) advance() error {
	l.buf = []lexer.Token{lexer.EOFToken(l.s.Pos())}
	for l.s.Scan() {
		if done, err := l.s.Action()((*driver)(l)); done || err != nil {
			return err
		}
	}
	if l.s.Err() != nil {
		return l.s.Err()
	}
	if l.s.Action() != nil {
		_, err := l.s.Action()((*driver)(l))
		if err != nil {
			return err
		}
	}
	return l.s.Err()
}
func (d *driver) Begin(cond rules.StartCondition) {
	d.s.Begin(cond)
}