Skip to content

Commit 6d6d5b2

Browse files
committed
---
yaml --- r: 555 b: refs/heads/master c: eecd1f4 h: refs/heads/master i: 553: 00a51c8 551: 4ea65ed v: v3
1 parent 12dee25 commit 6d6d5b2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 1db0cb208de058ea2d1d5b2d2982a482d55de3b8
2+
refs/heads/master: eecd1f47d78d2f4144999aa6901f75799e6bcec0

trunk/src/comp/fe/lexer.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import std._io.stdio_reader;
22

33
fn in_range(char c, char lo, char hi) -> bool {
4-
ret c <= lo && c <= hi;
4+
ret lo <= c && c <= hi;
55
}
66

77
fn is_alpha(char c) -> bool {
@@ -37,21 +37,25 @@ fn next_token(stdio_reader rdr) -> token.token {
3737
}
3838

3939
if (c == eof) { ret token.EOF(); }
40+
4041
if (is_alpha(c)) {
4142
while (is_alpha(c)) {
4243
accum += (c as u8);
4344
c = rdr.getc() as char;
44-
ret token.IDENT(accum);
4545
}
46+
rdr.ungetc(c as int);
47+
ret token.IDENT(accum);
4648
}
4749

4850
if (is_dec_digit(c)) {
4951
if (c == '0') {
5052
} else {
5153
while (is_dec_digit(c)) {
5254
accum += (c as u8);
53-
ret token.LIT_INT(0);
55+
c = rdr.getc() as char;
5456
}
57+
rdr.ungetc(c as int);
58+
ret token.LIT_INT(0);
5559
}
5660
}
5761

0 commit comments

Comments
 (0)