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)
| 86 | // r, size := utf8.DecodeRune(input[pos.Index:]) |
| 87 | // pos.AdvanceRune(r, size) // Move past this rune |
| 88 | func (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. |
no outgoing calls
no test coverage detected