scanner

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewNumValFn = func(constant.Value, string, bool) interface{} {
	return struct{}{}
}

NewNumValFn allows us to use tree.NewNumVal without a dependency on tree.

View Source
var NewPlaceholderFn = func(string) (interface{}, error) {
	return struct{}{}, nil
}

NewPlaceholderFn allows us to use tree.NewPlaceholder without a dependency on tree.

Functions

func HasMultipleStatements

func HasMultipleStatements(sql string) (multipleStmt bool, err error)

HasMultipleStatements returns true if the sql string contains more than one statements. An error is returned if an invalid token was encountered.

func LastLexicalToken

func LastLexicalToken(sql string) (lastTok int, ok bool)

LastLexicalToken returns the last lexical token. If the string has no lexical tokens, returns 0 and ok=false.

Types

type ScanSymType

type ScanSymType interface {
	ID() int32
	SetID(int32)
	Pos() int32
	SetPos(int32)
	Str() string
	SetStr(string)
	UnionVal() interface{}
	SetUnionVal(interface{})
}

ScanSymType is the interface for accessing the fields of a yacc symType.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner lexes SQL statements.

func (*Scanner) Cleanup

func (s *Scanner) Cleanup()

Cleanup is used to avoid holding on to memory unnecessarily (for the cases where we reuse a Scanner).

func (*Scanner) In

func (s *Scanner) In() string

In returns the input string.

func (*Scanner) Init

func (s *Scanner) Init(str string)

Init initializes a new Scanner that will process str.

func (*Scanner) Pos

func (s *Scanner) Pos() int

Pos returns the current position being lexed.

func (*Scanner) Scan

func (s *Scanner) Scan(lval ScanSymType)

Scan scans the next token and populates its information into lval.

func (*Scanner) ScanComment

func (s *Scanner) ScanComment(lval ScanSymType) (present, ok bool)

ScanComment scans the input as a comment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL