MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / AdvanceRune

Method AdvanceRune

pkg/sql/tokenizer/position.go:88–104  ·  view source on GitHub ↗

AdvanceRune moves the position forward by one UTF-8 rune. This updates the byte index, line number, and column number appropriately. Newline Handling: When r is '\n', the line number increments and the column resets to 1. Parameters: - r: The rune being consumed (used to detect newlines) - size: T

(r rune, size int)

Source from the content-addressed store, hash-verified

86// r, size := utf8.DecodeRune(input[pos.Index:])
87// pos.AdvanceRune(r, size) // Move past this rune
88func (p *Position) AdvanceRune(r rune, size int) {
89 if size == 0 {
90 size = 1 // fallback to single byte
91 }
92
93 // Move forward by the rune's size
94 p.Index += size
95
96 // Handle newlines
97 if r == '\n' {
98 p.Line++
99 p.LastNL = p.Index
100 p.Column = 1
101 } else {
102 p.Column++
103 }
104}
105
106// AdvanceN moves the position forward by n bytes and recalculates the line
107// and column numbers using the provided line start indices.

Callers 7

skipWhitespaceMethod · 0.80
readIdentifierMethod · 0.80
readQuotedIdentifierMethod · 0.80
readQuotedStringMethod · 0.80
readNumberMethod · 0.80
readPunctuationMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected