Documentation
¶
Overview ¶
Package scanner provides low-level scanning utilities for Go source code. These primitives handle string literals, comments, and bracket balancing while properly skipping over nested constructs.
Index ¶
- func IsBlockCommentStart(b []byte, i int) bool
- func IsLineCommentStart(b []byte, i int) bool
- func IsStringStart(b []byte, i int) bool
- func ScanBalanced(src []byte, open int, openChar, closeChar byte) int
- func ScanBalancedParen(src []byte, open int) int
- func ScanBlockComment(src []byte, i int) int
- func ScanLineComment(src []byte, i int) int
- func ScanString(src []byte, i int) int
- func SplitTopLevel(s string) []string
- func SplitTopLevelAny(s string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBlockCommentStart ¶
IsBlockCommentStart returns true if position i starts a /* comment.
func IsLineCommentStart ¶
IsLineCommentStart returns true if position i starts a // comment.
func IsStringStart ¶
IsStringStart returns true if position i starts a string literal (either double-quoted or backtick raw string).
func ScanBalanced ¶
ScanBalanced finds the matching close bracket for the open bracket at position. Generic version supporting any bracket pair. Returns -1 if not found.
func ScanBalancedParen ¶
ScanBalancedParen finds the matching ')' for '(' at position open. Skips over strings and comments. Returns the position of the closing ')', or -1 if not found.
func ScanBlockComment ¶
ScanBlockComment advances past a /* */ comment starting at position i. Returns the position after the closing */, or len(src) if unterminated.
func ScanLineComment ¶
ScanLineComment advances past a // comment starting at position i. Returns the position after the newline (or end of input).
func ScanString ¶
ScanString advances past a string literal starting at position i. Handles both double-quoted strings (with escape sequences) and backtick raw strings. Returns the position after the closing quote, or len(src) if unterminated.
func SplitTopLevel ¶
SplitTopLevel splits a string by commas at depth 0, respecting parentheses only. Used for function argument lists where brackets and braces are not relevant.
func SplitTopLevelAny ¶
SplitTopLevelAny splits by commas at depth 0, respecting (), [], and {}. Used when arguments may contain composite literals or array indexing.
Types ¶
This section is empty.