Merge pull request #7165 from GPotoshin/core_scanner_issue_7135

A fix to the issue #7153 and a test
This commit is contained in:
Jeroen van Rijn
2026-07-30 20:00:50 +02:00
committed by GitHub
2 changed files with 24 additions and 1 deletions

View File

@@ -377,8 +377,13 @@ scan_number :: proc(s: ^Scanner, ch: rune, seen_dot: bool) -> (rune, rune) {
ch, ds = digits(s, ch, base, &invalid)
digsep |= ds
if ch == '.' && .Scan_Floats in s.flags {
prev_s := s^
ch = advance(s)
seen_dot = true
if ch == '.' {
s^ = prev_s
} else {
seen_dot = true
}
}
}

View File

@@ -0,0 +1,18 @@
package test_core_text_scanner
import "core:testing"
import s "core:text/scanner"
@test
range_operator :: proc(t: ^testing.T) {
data := "0x00..=0xff"
h: s.Scanner
s.init(&h, data, "string")
h.flags = s.Odin_Like_Tokens - {.Skip_Comments}
testing.expect(t, s.Int == s.scan(&h), "token should be Int")
testing.expect(t, '.' == s.scan(&h), "token should be '.'")
testing.expect(t, '.' == s.scan(&h), "token should be '.'")
testing.expect(t, '=' == s.scan(&h), "token should be '='")
testing.expect(t, s.Int == s.scan(&h), "token should be Int")
testing.expect(t, s.EOF == s.scan(&h), "token should be EOF")
}