We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
peek_n
package text/scanner
1 parent 98c8fde commit 96d8971Copy full SHA for 96d8971
core/text/scanner/scanner.odin
@@ -160,6 +160,21 @@ peek :: proc(s: ^Scanner) -> rune {
160
return s.ch;
161
}
162
163
+peek_n :: proc(s: ^Scanner, n: int) -> rune {
164
+ assert(n >= 0);
165
+ if n == 0 {
166
+ return peek(s);
167
+ }
168
+
169
+ prev_s := s^;
170
+ for in 0..<n {
171
+ next(s);
172
173
+ ch := peek(s);
174
+ s^ = prev_s;
175
+ return ch;
176
+}
177
178
179
error :: proc(s: ^Scanner, msg: string) {
180
s.error_count += 1;
0 commit comments