aboutsummaryrefslogtreecommitdiff
path: root/core/text
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-12-07 11:30:54 +0000
committergingerBill <bill@gingerbill.org>2020-12-07 11:30:54 +0000
commitb9aa94ee0dcbdc986f2cfc2f34f8ffc8c41c8ef0 (patch)
treed785226d3fdd253f43e0ca71cd2c59ae616be74c /core/text
parent96d8971d87fbe4156fd1653a205a84cf66469bc7 (diff)
Add scan_peek_n to package text/scanner #800
Diffstat (limited to 'core/text')
-rw-r--r--core/text/scanner/scanner.odin10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/text/scanner/scanner.odin b/core/text/scanner/scanner.odin
index a3c44e909..bd1b24fe2 100644
--- a/core/text/scanner/scanner.odin
+++ b/core/text/scanner/scanner.odin
@@ -175,6 +175,16 @@ peek_n :: proc(s: ^Scanner, n: int) -> rune {
return ch;
}
+scan_peek_n :: proc(s: ^Scanner, n: int) -> (tok: rune) {
+ assert(n >= 0);
+ prev_s := s^;
+ for in 0..<n {
+ tok = scan(s);
+ }
+ tok = scan(s);
+ s^ = prev_s;
+ return;
+}
error :: proc(s: ^Scanner, msg: string) {
s.error_count += 1;