File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 1db0cb208de058ea2d1d5b2d2982a482d55de3b8
2
+ refs/heads/master: eecd1f47d78d2f4144999aa6901f75799e6bcec0
Original file line number Diff line number Diff line change 1
1
import std. _io . stdio_reader ;
2
2
3
3
fn in_range ( char c, char lo, char hi) -> bool {
4
- ret c <= lo && c <= hi;
4
+ ret lo <= c && c <= hi;
5
5
}
6
6
7
7
fn is_alpha ( char c) -> bool {
@@ -37,21 +37,25 @@ fn next_token(stdio_reader rdr) -> token.token {
37
37
}
38
38
39
39
if ( c == eof) { ret token. EOF ( ) ; }
40
+
40
41
if ( is_alpha ( c) ) {
41
42
while ( is_alpha ( c) ) {
42
43
accum += ( c as u8 ) ;
43
44
c = rdr. getc ( ) as char ;
44
- ret token. IDENT ( accum) ;
45
45
}
46
+ rdr. ungetc ( c as int ) ;
47
+ ret token. IDENT ( accum) ;
46
48
}
47
49
48
50
if ( is_dec_digit ( c) ) {
49
51
if ( c == '0' ) {
50
52
} else {
51
53
while ( is_dec_digit ( c) ) {
52
54
accum += ( c as u8 ) ;
53
- ret token . LIT_INT ( 0 ) ;
55
+ c = rdr . getc ( ) as char ;
54
56
}
57
+ rdr. ungetc ( c as int ) ;
58
+ ret token. LIT_INT ( 0 ) ;
55
59
}
56
60
}
57
61
You can’t perform that action at this time.
0 commit comments