source

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Overview

Package source provides source-preserving SQL lexical operations. It owns protected regions and nesting; consumers retain their own macro semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CriteriaBoundary

func CriteriaBoundary(source string) int

func FindCodeToken

func FindCodeToken(source, token string, start int) int

func FindLastTopLevelKeyword

func FindLastTopLevelKeyword(source, keyword string, start int) int

func FindTopLevelKeyword

func FindTopLevelKeyword(source, keyword string, start int) int

func HasTopLevelClause

func HasTopLevelClause(source, clause string) bool

func IsWhitespace

func IsWhitespace(value byte) bool

func MaskLineComments

func MaskLineComments(text string) string

MaskLineComments preserves byte offsets and newlines while removing only executable SQL line comments. Quoted '--' remains literal content.

func ProtectedRangeAt

func ProtectedRangeAt(source string, position int) (int, int, string)

ProtectedRangeAt returns the half-open quoted/comment span containing an offset. An empty kind means the offset is executable code or out of range.

func ProtectionAt

func ProtectionAt(source string, position int) string

func ReadGroupString

func ReadGroupString(source string, start int, open, close byte) (string, int, bool)

ReadGroupString returns the delimited source and its exclusive end offset.

func SplitArgs

func SplitArgs(source string) []string

func SplitTopLevelAlias

func SplitTopLevelAlias(source string) (string, string)

func SplitTopLevelCSV

func SplitTopLevelCSV(source string) []string

func TrimQuote

func TrimQuote(source string) string

func TrimQuotedArgs

func TrimQuotedArgs(args []string) []string

func ValidateStructure

func ValidateStructure(text string) error

ValidateStructure checks parentheses and protected-region closure without imposing a dialect grammar on executable expressions or template semantics.

Types

type CodeScanner

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

func NewCodeScanner

func NewCodeScanner(source string, start int) *CodeScanner

func (*CodeScanner) Next

func (s *CodeScanner) Next() (int, bool)

func (*CodeScanner) PreviousSignificant

func (s *CodeScanner) PreviousSignificant() (position int, kind string)

PreviousSignificant returns the last non-whitespace, non-comment byte before the byte just returned by a successful Next. Call it before advancing again. Quoted text is significant and has a nonempty kind; -1 means no preceding text. A lazy cursor reuses the protected-region lexer and advances through preceding SQL once across lookups, for O(n) total time and O(1) space.

type Token

type Token string

func (Token) Contains

func (t Token) Contains(source string) bool

func (Token) Find

func (t Token) Find(source string, start int) int

func (Token) ReplaceAll

func (t Token) ReplaceAll(source, replacement string) string

Jump to

Keyboard shortcuts

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