|
@@ -150,32 +150,26 @@ next :: proc(s: ^Scanner) -> rune {
|
|
return ch;
|
|
return ch;
|
|
}
|
|
}
|
|
|
|
|
|
-peek :: proc(s: ^Scanner) -> rune {
|
|
|
|
|
|
+peek :: proc(s: ^Scanner, n := 0) -> (ch: rune) {
|
|
if s.ch == -2 {
|
|
if s.ch == -2 {
|
|
s.ch = advance(s);
|
|
s.ch = advance(s);
|
|
if s.ch == '\ufeff' { // Ignore BOM
|
|
if s.ch == '\ufeff' { // Ignore BOM
|
|
s.ch = advance(s);
|
|
s.ch = advance(s);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return s.ch;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-peek_n :: proc(s: ^Scanner, n: int) -> rune {
|
|
|
|
- assert(n >= 0);
|
|
|
|
- if n == 0 {
|
|
|
|
- return peek(s);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- prev_s := s^;
|
|
|
|
- for in 0..<n {
|
|
|
|
- next(s);
|
|
|
|
|
|
+ ch = s.ch;
|
|
|
|
+ if n > 0 {
|
|
|
|
+ prev_s := s^;
|
|
|
|
+ for in 0..<n {
|
|
|
|
+ next(s);
|
|
|
|
+ }
|
|
|
|
+ ch = s.ch;
|
|
|
|
+ s^ = prev_s;
|
|
}
|
|
}
|
|
- ch := peek(s);
|
|
|
|
- s^ = prev_s;
|
|
|
|
return ch;
|
|
return ch;
|
|
}
|
|
}
|
|
|
|
|
|
-scan_peek_n :: proc(s: ^Scanner, n: int) -> (tok: rune) {
|
|
|
|
|
|
+peek_token :: proc(s: ^Scanner, n := 0) -> (tok: rune) {
|
|
assert(n >= 0);
|
|
assert(n >= 0);
|
|
prev_s := s^;
|
|
prev_s := s^;
|
|
for in 0..<n {
|
|
for in 0..<n {
|