{"modulePath":"github.com/cockroachdb/cockroachdb-parser","version":"v0.25.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package scanner\n\n## Variables\n\n```go\nvar NewNumValFn = func(constant.Value, string, bool) interface{} {\n\treturn struct{}{}\n}\n```\nNewNumValFn allows us to use tree.NewNumVal without a dependency on tree.\n\n```go\nvar NewPlaceholderFn = func(string) (interface{}, error) {\n\treturn struct{}{}, nil\n}\n```\nNewPlaceholderFn allows us to use tree.NewPlaceholder without a dependency on tree.\n\n## Functions\n\n```go\nfunc FirstLexicalToken(sql string) (tok int)\n```\nFirstLexicalToken returns the first lexical token. Returns 0 if there is no token.\n\n```go\nfunc HasMultipleStatements(sql string) (multipleStmt bool, err error)\n```\nHasMultipleStatements returns true if the sql string contains more than one statements. An error is returned if an invalid token was encountered.\n\n```go\nfunc LastLexicalToken(sql string) (lastTok int, ok bool)\n```\nLastLexicalToken returns the last lexical token. If the string has no lexical tokens, returns 0 and ok=false.\n\n## Types\n\n```go\ntype InspectToken struct {\n\tID      int32\n\tMaybeID int32\n\tStart   int32\n\tEnd     int32\n\tStr     string\n\tQuoted  bool\n}\n```\nInspectToken is the type of token that can be scanned by Inspect.\n\n```go\nfunc Inspect(sql string) []InspectToken\n```\nInspect analyses the string and returns the tokens found in it. If an incomplete token was encountered at the end, an InspectToken entry with ID -1 is appended.\n\nIf a syntax error was encountered, it is returned as a token with type ERROR.\n\nSee TestInspect and the examples in testdata/inspect for more details.\n\n```go\ntype JSONPathScanner struct {\n\tScanner\n}\n```\nJSONPathScanner is a scanner with a jsonpath-specific scan function.\n\n```go\nfunc (s *JSONPathScanner) Scan(lval ScanSymType)\n```\nScan scans the next token and populates its information into lval. This scan function contains rules for jsonpath.\n\n```go\ntype PLpgSQLScanner struct {\n\tScanner\n}\n```\nPLpgSQLScanner is a scanner with a PLPGSQL specific scan function\n\n```go\nfunc (s *PLpgSQLScanner) Scan(lval ScanSymType)\n```\nScan scans the next token and populates its information into lval. This scan function contains rules for plpgsql.\n\n```go\ntype SQLScanner struct {\n\tScanner\n}\n```\nSQLScanner is a scanner with a SQL specific scan function\n\n```go\nfunc (s *SQLScanner) Scan(lval ScanSymType)\n```\nScan scans the next token and populates its information into lval.\n\n```go\ntype ScanSymType interface {\n\tID() int32\n\tSetID(int32)\n\tPos() int32\n\tSetPos(int32)\n\tStr() string\n\tSetStr(string)\n\tUnionVal() interface{}\n\tSetUnionVal(interface{})\n}\n```\nScanSymType is the interface for accessing the fields of a yacc symType.\n\n```go\ntype Scanner struct {\n\n\t// Comments is the list of parsed comments from the statement.\n\tComments []string\n\t// contains filtered or unexported fields\n}\n```\nScanner lexes statements.\n\n```go\nfunc (s *Scanner) Cleanup()\n```\nCleanup is used to avoid holding on to memory unnecessarily (for the cases where we reuse a Scanner).\n\n```go\nfunc (s *Scanner) In() string\n```\nIn returns the input string.\n\n```go\nfunc (s *Scanner) Init(str string)\n```\nInit initializes a new Scanner that will process str.\n\n```go\nfunc (s *Scanner) Pos() int\n```\nPos returns the current position being lexed.\n\n```go\nfunc (s *Scanner) RetainComments()\n```\nRetainComments instructs the scanner to collect SQL comments in the Comments field.\n\n```go\nfunc (s *Scanner) ScanComment(lval ScanSymType) (present, ok bool)\n```\nScanComment scans the input as a comment.\n\n","path":"github.com/cockroachdb/cockroachdb-parser/pkg/sql/scanner","name":"scanner","synopsis":"","isRedistributable":true}
